AngularJS Tutorial - Create object in ng-init








The following code shows how to Create object in ng-init.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<body ng-app>
    <div ng-init="user.name='John'; user.age=50">
      {{user.name}} is {{user.age}} years old.
    </div><!--   ww  w  .j  a va  2s  .  c om-->
</body>
</html>

The code above is rendered as follows: