Below I have the Angular Bootstrap Empowerment and I'm trying to explain how each acordian panel will have to scope in the array properly.
For example, below I have an amarantin and inside each panel, I print an array called 'item' I am The add item adds a new item to the button array and updates every panel. My question is, how do I change the array in the panel only, where I clicked the configuration button and did not update the array in other panels? Do I need to create an instance of the item array for each panel?
& lt; Accordion & gt; & Lt; Accordion-group ng-repeat = "Postcodlist" in the Product & gt; & Lt; Accordion-title & gt; {{Product}} & lt; / Accordion-heading & gt; & Lt; A ng-click = "addItem ()" & gt; Add item & lt; / A & gt; {{Item}} & lt; / Accordion-group & gt;
$ scope.items = ['item1', 'item2', 'item3']; $ Scope.addItem = function () {var newItemNo = $ scope.items.length + 1; $ Scope.items.push ('item' + no new item); };
I think you need to create an instance of the item array for each panel is . Otherwise everything will eventually get confused. My revision:
and script:
$ scope.postcodelist = ['post01', 'post02', 'post03']; $ Scope.itemsOfProduct = {}; $ Scope.addItemToProduct = function (index) {var newItemNo; $ Scope.itemsOfProduct [$ scope.postcodelist [index]] = $ scope.itemsOfProduct [$ scope.postcodelist [index]] || []; NewItemNo = $ scope.itemsOfProduct [$ scope.postcodelist [index]] Length + 1; $ Scope.itemsOfProduct [$ scope.postcodelist [index]]. Push ('item' + no new item); }
No comments:
Post a Comment