Directive ng-init in AngularJS
This sample will help you know about using ng-init in AngularJS.
<html> <head> <title>Angular JS Model</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> <script> angular.module('MyForm', []) .controller('myController', ['$scope', function($scope) { }]); </script> </head> <body ng-app="MyForm"> <ul
ng-init
=" students = [ {name: 'thehalfheart@gmail.com', age: 25, gender: 'boy'}, {name: 'freetuts.net', age: 30, gender: 'girl'}, {name: 'Johanna', age: 28, gender: 'girl'}, {name: 'Joy', age: 15, gender: 'girl'}, {name: 'Mary', age: 28, gender: 'girl'}, {name: 'Peter', age: 95, gender: 'boy'}, {name: 'Sebastian', age: 50, gender: 'boy'}, {name: 'Erika', age: 27, gender: 'girl'}, {name: 'Patrick', age: 40, gender: 'boy'}, {name: 'Samantha', age: 60, gender: 'girl'} ] "> <li ng-repeat="student in students"> Name: {{student.name}}, Age {{student.age}}, Gender: {{student.gender}} </li> </ul> </body> </html>
Thanks for your reading time.
No comments:
Post a Comment