Using md-select with a presetted ng-model the relative md-option is not highlighted nor marked as selected if the model referes to an object. But when the user select an option then this is marked as selected and is highlighted correctly.
The problem is more markable when the default value is not the first in the list, because the first element gets an highlight effect (different from the select one).
If the model refers to a primitive type, such as a number, it works as expected.
You can use ng-model-options in order to tell how to keep track of your objects
http://codepen.io/myagoo/pen/Qbddzg
But "trackBy" is not documented to be a valid key for ng-model-options, https://code.angularjs.org/1.3.15/docs/api/ng/directive/ngModelOptions
So, the fact that it works is a bug or a not documented feature?
Very good... thx @myagoo.
Hello.
I tried track by, but it did not work as I expected. Also in the codepen, does not allow to change the value.
So I wrote a program which does the same thing with md-select-label and selected option.
Hope it helps you.
http://codepen.io/1kohei1/pen/gpXdjQ?editors=101
+1
This feature seems to be currently broken, even the codepen example is broken (as @1kohei1 says). I realize that fixing an undocumented feature isn't top-priority, but the code itself _does_ have a TODO of documenting said feature. Hopefully the feature is fixed before the documentation happens. :^)
@bsandrow the feature works with trackBy. See this demo. We do need to document it though
+1
I'm using this in order to highlight the data:
ng-model-options="{ trackBy: '$value.id' }"
Most helpful comment
Hello.
I tried track by, but it did not work as I expected. Also in the codepen, does not allow to change the value.
So I wrote a program which does the same thing with md-select-label and selected option.
Hope it helps you.
http://codepen.io/1kohei1/pen/gpXdjQ?editors=101