Javascript-форум (https://javascript.ru/forum/)
-   Angular.js (https://javascript.ru/forum/angular/)
-   -   Does not display the value by the key of the selected Json. (https://javascript.ru/forum/angular/67066-does-not-display-value-key-selected-json.html)

Nadirbek 26.01.2017 15:37

Does not display the value by the key of the selected Json.
 
<select ng-model="selectedFaculty">
<option ng-repeat="faculty in faculties" value="{{faculty}}">{{faculty.Name}}</option>
</select>
<h1>Selected faculty: {{selectedFaculty}}</h1>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.faculties=[{Id:1,Name:'Economics'},{Id:2,Name:'IT'},{Id:3,Nam e:'Tourism'}];
});
</script>
If I will put selectedFaculty.Name instead of selectedFaculty then nothing is displayed in the page.
How can this be explained?

destus 26.01.2017 17:17

Nadirbek,
option.value must be a string


Часовой пояс GMT +3, время: 15:22.