Friday, June 26, 2015

AngularJS Expressions using Objects

In the post AngularJS Expressions using String and Numbers, we saw on how to use simple string and numbers in expressions, we can also create complex objects and use them in expressions, this becomes more handy when we want to implement MVC pattern using AngularJS, we can define model objects and use them in the View layer to display model object properties.

The following example shows how to use Objects in Expressions

<html ng-app>
    <meta charset="utf-8" />
    <title>AngularJS - Basic</title>
    <script src="angular.min.js"></script>
          <div ng-init="Employee={name:'John',age:25,dob:'01-01-1990'}">
                   <p>Name :<b> {{ }} </b></p>
                   <p>Age :<b> {{ Employee.age }} </b></p>
                   <p>DOB :<b> {{ Employee.dob }} </b></p>


Search Flipkart Products:

No comments: