how to list array of object literals using service in angularjs with and example programs -
<!doctype html> <html ng-app="shoppinglistapp"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script> <body> <div ng-controller='shoppinglistshowcontroller showlist'> <ol> <li ng-repeat="item in showlist.items"> {{item.quantity}}of{{item.name}} </li> </ol> <script> {angular.module('shoppinglistapp',[]) .controller('shoppinglistshowcontroller',shoppinglistshowcontroller) .service('shoppinglistservice',shoppinglistservice); shoppinglistshowcontroller.$inject=['shoppinglistservice']; function shoppinglistshowcontroller(shoppinglistservice,function($scope)) { $scope.showlist.items=shoppinglistservice.getitems(); } function shoppinglistservice() { var service=this; var items=[{ name:"d", quantity:"d" }]; this.getitems=function() {return items;}; }} </script> </body> </html>
i need list entire items prepopulated array of object literals in service , need function using remove button remove listed items list , adding list needs in same service.i need 2 controllers 1 should focus on items displayed using list , should check if items not present in second list while pressing remove button should removed 1 list , added list
Comments
Post a Comment