material
material copied to clipboard
feat(radio-group): support ng-model-options trackBy
similar to #2862 md-radio-group doesn't set value to be selected if it is using objects and using a pre set value. plunkr to illustrate it doesn't work.
For md-select this was fixed by setting ng-model-options="{trackBy: '$value.id'}"
It would be nice if md-radio-group had something similar. Or is it possible to achieve the same behavior?
+1 @ThomasBurleson why is this labeled with Deprecated ?
You have to put ng-model
and ng-model-options
on the <md-radio-button>
element. It will work correctly if you do this.
@GustavSt I've been struggling with this. Using ng-click as a workaround (plunkr), but it has obvious limitations.
I have exactly the same problem. We switched the core software to angular material and now we need object model support on the md-radio-button. Selecting is fine, but we cannot make the form initialize with the radio button set based on the model property. I tried using ng-class="{'md-checked':EXPRESSION}" but it immediately gets overridden moments after applying the md-checked. I am at a loss at how to acheive this functionality in angular material. bsandrow's suggestion did not work.
@bsandrow - md-radio-button does not support ng-model. Can you post working sample?
I verified that this is still not supported in 1.1.8 by using this updated Plunker.
I can see how this could be helpful as the use cases described above are clear and may be commonly encountered. This is also a standard feature of AngularJS that would be nice to support.
I am reopening this as we would welcome a contribution from the community to add ng-model-options
support to md-radio-group
.
Workaround: find the matching value in the options, and assign that to the ng-model: https://codepen.io/jakobadam/pen/rvjRRg?editors=1010