AngularJS Tutorial - Create Date type in ng-init








The following code shows how to create Date type in ng-init.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!-- w w  w  .  ja v  a2s .  c o  m-->
<body>
  <div ng-app ng-init="modifiedDate = '2013-07-09T22:22:22.2425232+08:00'">
    <input type="text" ng-model="modifiedDate"/>
    <h1>{{ modifiedDate | date:'short' }}</h1>
    <h1>{{ modifiedDate }}</h1>
</div>
<script type='text/javascript'>
</script>
</body>
</html>

The code above is rendered as follows: