Its a very simple problem. Don't quite understand why this is not working.
I have a directive which is displaying a bunch of checkboxes using ng-repeat. I want to do 2 things:
I want to display the checkboxes selected if the attribute in the model has the respective value in list of selected values ( i.e. in the plunker
fruitselected =["apple","banana"]
then apple and banana should be selected.I want to store the values of any checkbox selection to the ng-model, which here would be list of selected fruits (i.e. in the plunker fruitselected will be
fruitselected=["apple", "banana", "orange"]
if all 3 were selected.
Here is the plunker :http://ift.tt/1CeCW4g
Following is my code in the template :
> <div ng-repeat=" fruit in data "> <input type="checkbox"
> ng-model="fruitselected" value="fruit.type"
> ng-change="changefunction(fruit.type)"/>{{fruit.type}}
> </div> SelectedFruits: {{fruitselected}}
Appreciate your help!
Aucun commentaire:
Enregistrer un commentaire