Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.slugs = [
- {id: 1, name: 'angular-directives'},
- {id: 23, name: 'composing-your-very-own-angular-directives'},
- {id: 70, name: 'directives-in-angular-js'},
- ];
- $scope.slugs=[{id:1,name:'angular-directives'},{id:23,name:'composing-your-very-own-angular-directives'},{id:70, name:'directives-in-angular-js'}];
- $scope.names=[]; //for ng-list
- $scope.newSlugs = [];
- //loop through every element in array slugs
- $scope.slugs.forEach(function(ele,index,array){
- //for ng-list
- $scope.names.push(ele.name);
- //create a new obj with one attribute 'name'
- $scope.newSlugs.push({name:ele.name});
- //register observer to every slug, update the name of obj in newSlugs once user had updated the name
- $scope.$watch("names["+index+"]",function(newValue,oldValue){
- $scope.slugs[index].name=newValue;
- $scope.newSlugs[index].name=newValue;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement