Answer the question
In order to leave comments, you need to log in
How to add an array of objects to ng-model from a directive?
There is a form for filling out a product card. I need to enter the name of the product and an array of possible colors for this product in the form of objects { id : '1232','name':'Green','type':'colors'}
Everything is clear with the name of the product. But there is a problem with flowers. Colors are sent to the form as a directive
, which is output using ng-repeat
<div ng-repeat="color in colors" >
<add-product data="color.name" id="color.id" type="color" model="colors"></add-product>
</div>
template: '<button ng-click="deleteFromBasket(id,data,type)">{{data}}</button>',
{ name: 'BMW', colors : [{'id':'12312','name':'blue','type':'colors'},{id:'12432','name':'white','type':'colors'},{id:'123232','name':'green','type':'colors'}]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question