1

Im following this doc for md-select initial value setting. But i would like to set the value of md-select programmatically through buttons.

Here is what ive'd done so far DEMO

Shift 'n Tab
  • 8,808
  • 12
  • 73
  • 117

1 Answers1

1

md-select is expecting object value to be there in selectedUser, where as filter does return array of filtered object. You should be assigning 1st element of filtered array by doing [0] of filtered result.

$scope.selectedUser = $scope.users.filter(function(user) {
     return user.id == id;
})[0];

Forked Codepen

Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299