Material: mdSelect: not displaying the initial value of ngModel when it's an object

Created on 28 May 2015  路  5Comments  路  Source: angular/material

Hi,

I'm having a problem with mdSelect + ngRepeat with objects in the value.
When i initialize the ngModel value while loading the page (like i would if i was, for example, editing some object i get from the server).
The mdSelect doesn't match my object and have it selected as it does when i use something as simple as an array of strings.

example:
http://codepen.io/VictorRicha/pen/BNQezv

fixed docs

Most helpful comment

Problem solved!
Turns out i had to use ng-model-options="{trackBy: 'someVal.value'}"
It would be nice to see this in the documentation

All 5 comments

try ng-value="val.value" on the md-option.

http://codepen.io/anon/pen/PqbrwY

@JerrodLong Didnt work for me. Also tried your way using track by val.value in the ngRepeat with no success :disappointed:

Problem solved!
Turns out i had to use ng-model-options="{trackBy: 'someVal.value'}"
It would be nice to see this in the documentation

Or just do this: ng-disabled="$index === 1"

This is documented now in https://material.angularjs.org/latest/api/directive/mdSelect#selects-and-object-equality

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bobber205 picture bobber205  路  3Comments

WebTechnolog picture WebTechnolog  路  3Comments

kasajian picture kasajian  路  3Comments

ghost picture ghost  路  3Comments

PeerInfinity picture PeerInfinity  路  3Comments