over 7 years ago
With the help of Angularjs, We can dynamically add or remove list items in an array. It is shown In the example given below.
Addition of the list items is done using 'push' method and removal of the item is done using “splice” method. Controller-
<div ng-app="myApp"> <ul ng-controller="ItemsController" class="nav"> <input type="text" value="ItemName" ng-model="newItemName" placeholder="name of new item..."> <button ng-click="addItem()">Add Me</button> <li ng-repeat="item in items.data" id="item{{item.id}}"> <a href="#">{{item.title}}</a> <a ng-click="deleteItem($index)" class="delete-item">x</a> </li> </ul> </div>
'push' Method-
$scope.addItem = function (index) { items.data.push({ id: $scope.items.data.length + 1, title: $scope.newItemName }); }
“splice” Mehod-
$scope.deleteItem = function (index) { items.data.splice(index, 1); }
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)