Trying to figure out how to get the id and name of the selected item in angular. Basically brand new to js and angular so not quite sure what I'm doing wrong. I'm sure its something simple I'm missing.
I have an html element that looks like:
<md-input-container>
<label>Difficulty</label>
<md-select ng-model="difficulty" ng-change="update()">
<md-option ng-repeat="difficulty in difficulties">
{{difficulty.Name}}
</md-option>
</md-select>
</md-input-container>
Calling an api to get the list of difficulties gives back the following json
[{DifficultyID: 1, Name: "Easy"}, {DifficultyID: 2, Name: "Medium"}, {DifficultyID: 3, Name: "Hard"}]
In my controller I have defined the method
$scope.update = function () {
console.log($scope.item.Name);
}
Always get an undefined for Name.