Mohamed Nizar
Mohamed Nizar

Reputation: 777

md-select not selected when the ng-value is an object

  <md-select name='services' ng-model="vm.service.service_group" placeholder="Select a  Group"  required>
      <md-option ng-value="opt" ng-repeat="opt in vm.service_group" ng-selected="true" >{{ opt.name }}</md-option>
  </md-select>

I have this select option in my form.This will not get selected on edit the object.How can make the ng-model to be selected on edit?

Thanks

Upvotes: 1

Views: 1273

Answers (1)

Mohamed Nizar
Mohamed Nizar

Reputation: 777

Finally, I got to resolve it.I added ng-selected="opt.code==vm.service.service_group.code" to check the selected values.

<md-select name='services' ng-model="vm.service.service_group" placeholder="Select a  Group"  required>
     <md-option ng-value="opt" ng-repeat="opt in vm.service_group" ng-selected="opt.code==vm.service.service_group.code" >{{ opt.name }}</md-option>
</md-select>

Hope this will help some one

Upvotes: 4

Related Questions