javascript - How to store the data in this json format? -
given following desired json api format:
"type_of_advertisement":["atm","banner/poster","stalls"]
i have defined ng-model this:
.form-group .col-sm-offset-2.col-sm-10 label.checkbox-inline input(type='checkbox', value='atm', ng-model='type_of_advertisement') | atm label.checkbox-inline input(type='checkbox', value='mobile/communication tower', ng-model='type_of_advertisement') | mobile/communication tower label.checkbox-inline input(type='checkbox', value='banner/poster', ng-model='type_of_advertisement') | banner/poster label.checkbox-inline input(type='checkbox', value='hoarding board', ng-model='type_of_advertisement') | hoarding board label.checkbox-inline input(type='checkbox', value='stalls', ng-model='type_of_advertisement') | stalls label.checkbox-inline input(type='checkbox', value='digital offline marketing', ng-model='type_of_advertisement') | digital offline marketing label.checkbox-inline input(type='checkbox', value='area product display', ng-model='type_of_advertisement') | area product display
and have got json format when post on angular having code is:
type_of_advertisement:[$scope.type_of_advertisement]
but following instead:
"type_of_advertisement":["true"]
so can desired json api format?
you value of checkbox. checkbox eather checked or unchecked (true or false). don't know expect.
you must define different model each checkbox. , when build object, add value in array if checkbox checked.
i don't think there easier way this.
Comments
Post a Comment