I need to pre-select a specfic element in a Select tag.
My model is this:
{
user: 'mjones',
idprofile: 2,
profiles: [
{idprofile: 1, profile: 'admin'},
{idprofile: 2, profile: 'read-write'},
{idprofile: 3, profile: 'read-only'},
]
}
This represents a "user", and I attached a list of profiles to it, before opening a form with user-data, containing a select, for choosing the appropriate profile.
As you can see, the user object doesn't contain a "profile" object, but just it's idprofile. That's the difference between my object and those published in ngSelect documentation.
My view contains the select element as this:
<select class="form-control"
ng-model="user"
ng-options="profile.idprofile for profile in user.profiles">
</select>
This populates the list as expected, but it does not selects the idprofile: 2.
How can I match the idprofile from the user object with one element in the profiles array?, I prefer to work only on the view.