Thursday, 15 March 2012

javascript - Select menu, match json list with singular value -


I have a JSON file of US states, name and 2-letter code, which is a menu through the factory / controller variable ["Name": "Alabama", "code": "AL"}, {"name": "alaska",

for "code"
 : "ak"}, ...]  

Therefore, I use it for my menu: ng-options = "id's For s.code id.usStates "

works fine, displays my states.

Back-End Dev wants to link me with Jason, and also has this value:

So I created this item as "", "State", "AL", "Postal code": "000000", "ZIP 4": "", "country code" Tried to add as my ng-model,

  & lt; Select ng-model "id.partner.partnerAddressInfo.stateProvince" Ng-option = "s.code for id.usStates s" & gt; & Lt; / Select & gt;  

But there is no "link" with value in backend data, that is, it does not show "AL". So, I think I need to change my syntax somehow, but I am confused here ... the selected documents are also a bit confusing.

I created a simplified planer to show the situation:

If I am wrong I am not, and understand your question, then you are looking for this solution.

> Enter your HTML

  & lt; Select class = "form-control" ng-model = "selected" ng-init = "selected = partner.partnerAddressInfo.stateProvince" ng-option = "select S.cn as s.name for us s Location "& gt; & Lt; / Select & gt;  

Let me know I'm right.


No comments:

Post a Comment