Create object in ng-init

Description

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><!--from w  w w .java 2s . c o  m-->
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities