Angular Js List
How to create List in Angular js
by Nhat Nguyen
HTML
<div ng-app>
<ul ng-controller='studentListController'>
<li ng-repeat='student in students'> <a href="student/view/{{student.id}}">{{student.name}}</a>
</li>
<button ng-click="insertTom()">Insert</button>
</ul>
</div>
JavaScript
var students = [{
name: 'Nhat',
id: '1'
}, {
name: 'Jackys',
id: '2'
}, {
name: 'Joe',
id: '3'
}];
function studentListController($scope) {
$scope.students = students;
$scope.insertTom = function () {
$scope.students.splice(1, 0, {
name: 'Tom Thumb',
id: '4'
});
};
}