This article explains how can we reference the property of an object within the ng-repeat.
We all know that the we can render the value of a property in an object like below
Assume we have an object called Employee defined as
Now by using the following code we can show all the properties and its values of Employee
Output of the above code is
We all know that the we can render the value of a property in an object like below
<ul>
<li>{{object.propertyName}}</li>
</ul>
Reference the property of an object within the ng-repeat:
Assume we have an object called Employee defined as
var employee = { name:"John",
age:24,
designation:"Developer"
};
age:24,
designation:"Developer"
};
Now by using the following code we can show all the properties and its values of Employee
<ul>
<li ng-repeat="(key,val) in employee">{{key}}: {{val}}</li>
</ul>
Output of the above code is
- age: 24
- designation: Developer
- name: John
In this way, we can reference the property of an object within the ng-repeat.
For working example check this fiddle : reference the property name within ng-repeat
For more posts on AngularJS visit : AngularJS
No comments:
Post a Comment