[email protected]      beta
Donate

Object expressions in AngularJS

Overview: Understanding Object Expressions in AngularJS, What is Object Expressions, Use of AngularJS Object expression with an example, AngularJS binds data to HTML using Expressions..

AngularJS Object Expressions

AngularJS Object Expression is same as JavaScript objects. Objects are like variables, but it contains many values. Objects are written in a key value pair. The object expressions used to hold object properties and evaluate at the view where they are applied on web page.

AngularJS example using object expressions.

Example 1 : Here we are going to read JSON data from ng-init and display fullname using object expressions. The code looks like as written below.

<div ng-app="" ng-init="user= {firstName:'Satinder ',lastName:'Singh',gender:'Male'}" >
    <p> My FullName is  {{ user.firstName+ +user.lastName }} </p>
</div>

Same example can also be written using ng-bind directive in angularjs. Final code looks like as writte below.

<div ng-app="" ng-init="user= {firstName:'Satinder ',lastName:'Singh',gender:'Male'}" >
    <p> My FullName is  <span ng-bind="user.firstName+ +user.lastName" > </span> </p>
</div> 

Output: My FullName is Satinder Singh

Try It Yourself ⇒


  Popular Tag
  Recent Posts
  Follow Us
If you find these tutorials helpful then please donate. It will lead me to do more tutorials.
Donate