Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

ANGULAR

<input class="" name="store_category[]" type="checkbox"  ng-model="store.store_category.A">A

<input name="store_category[]" type="checkbox" ng-model="store.store_category.B">B

<button type="submit" ng-click="addStore(store)"  class="btn btn-primary campwidth">SUBMIT</button>

when I console it. It shows object.

store_category

Object { A=true,  B=true}

A true B true

I want to send it an array. How to do this in angularjs.

share|improve this question
    
Try using ng-true-value & ng-false-value attributes for a checkbox form control. Assign the object in ng-true-value. So when later you post your form the array would be array of objects. – Coder John Oct 12 '15 at 11:14
    
won't iterating over object and pushing to new Array work according to the Data structure needed? – Vaibhav Oct 12 '15 at 11:16
    
Note that using an array, you'll loose A and B keys because JS Arrays keys are integers unless you store them as individual objects in the array. Make an empty array. iterate over your store_category object and push to the empty array. – Farzad YZ Oct 12 '15 at 11:55
    
@Nivin Please find this: plnkr.co/edit/ql4e1PKhZvwSoCMgHDOH?p=preview – Coder John Oct 12 '15 at 11:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.