Reputation: 9443
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
Upvotes: 1
Views: 579
Reputation: 136144
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];
Upvotes: 1