In the first snippet, when using ng-value directive, ng-value= to json, behave like an object, I can get the json format and use it like an object. But, if I am using value attribute instead I can't use it like an obejct. Why in the second snippet I can't display {{selectedName.a}} ? Thanks
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedName">
<option ng-repeat="item in names" ng-value="{{item}}">{{item.a }}</option>
</select>
<p>{{selectedName}}</p> <!-- its a json stracture but -->
<p>{{selectedName.a}}</p> <!-- behave like an object?!?!? -->
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.names = [
{"a":"Emil1", "b":"Tobias1", "c":"Linus1"},
{"a":"Emil2", "b":"Tobias2", "c":"Linus2"},
{"a":"Emil3", "b":"Tobias3", "c":"Linus3"}
];
});
</script>
<p>This example shows how to fill a dropdown list using the ng-options directive.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedName">
<option ng-repeat="item in names" value="{{item}}">{{item.a }}</option>
</select>
<p>{{selectedName}}</p>
<p>{{selectedName.a}}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.names = [
{"a":"Emil1", "b":"Tobias1", "c":"Linus1"},
{"a":"Emil2", "b":"Tobias2", "c":"Linus2"},
{"a":"Emil3", "b":"Tobias3", "c":"Linus3"}
];
});
</script>
<p>This example shows how to fill a dropdown list using the ng-options directive.</p>
</body>
</html>