AngularJS: use sub-object attribute as ng-model
I have a dropdown which is bound to an object user with the following
structure:
{
userId:1,
userLogin:"test",
locale: { localeCode:"en-US" }
}
This structure comes directly from a C# model class where User and Locale
are two classes linked as an association (User has one Locale).
So I would like to define the following dropdown without doing any custom
logic like serializing the objects in a special way, or adding $watch to a
"UI" attribute so I can update locale.localeCode in the background.
<select id="dropLocale" required="required" addempty="true"
ng-model="user.locale.localeCode"
ng-options="i.localeCode as i.localeCode for i in
localeList"></select>
Any help will be appreciated! Thanks
No comments:
Post a Comment