angularjs - Trouble binding complex input to variable, efficiently -
i'm new angular , trying learn. trying find way bind quantities ids. here template:
"<div class='tableborder'><label> <input ng-model='" + modelngqty + "' type='number' name='{{value.detailid}}' /> {{value.text | lowercase}} </label> </div>"
the modelngqty is:
modelngqty = "selectedoptions[value.customid].details[value.detailid].qty";
unfortunately object gets generated code is:
{"36":{"details":{"107":{"qty":2323232},"108":{"qty":232323}}}}
i want this:
{"36":{"details":[{detailid: "107", "qty":2323232},{detailid: "108","qty":232323}]}}
here side-by-side visual of two. want 1 on left:
the version on right terribly hard loop through ng-repeat. have data cant figure out how write model. have tried {} , [], lot of different ngmodel versions. best version on right.
i have done lot of googling , there tons of resources on how filter , play ng-options ng-repeat couldn't find hardly inserting data model in format.
what missing here?
a possible solution exists @ http://plnkr.co/edit/9wmzad?p=info.
these map functions
vm.endingstructure= _.map(vm.beginningstructure, function(object, value) { var newstructure = {}; newstructure[value] = { details: _.map(object.details, function(qtyobject, value) { var arraystructure = { detailid: value, qty:qtyobject.qty }; return arraystructure; }) }; return newstructure; });
turns { "36": { "details": { "107": { "qty": 2323232 }, "108": { "qty": 232323 } } } }
[ { "36": { "details": [ { "detailid": "107", "qty": 2323232 }, { "detailid": "108", "qty": 232323 } ] } } ]
Comments
Post a Comment