Javascript 如何在Angularjs中传递从contextscope下拉列表中选择的值?

Javascript 如何在Angularjs中传递从contextscope下拉列表中选择的值?,javascript,angularjs,json,Javascript,Angularjs,Json,我有一个下拉列表 $scope.animals = [ {value:'lion', name:'lion', description: 'lion'}, {value:'cat', name:'cat', description: 'cat'}, {value:'dog', name:'dog', description: 'dog'}, ]; 我想把从下拉列表中选择的值作为contextscope传递给另一个指令。e、 g <md-s

我有一个下拉列表

$scope.animals = [
      {value:'lion', name:'lion', description: 'lion'}, 
      {value:'cat', name:'cat', description: 'cat'}, 
      {value:'dog', name:'dog', description: 'dog'}, 
    ];
我想把从下拉列表中选择的值作为contextscope传递给另一个指令。e、 g

<md-select ng-model="context">
    <md-option ng-repeat="animal in animals" value="{{animal.value}}"  aria-label="{{animal.name}}">{{animal.name}}</md-option>
</md-select>
<div described-type flex="70" contextscope="context"></div>

如何解决此错误并创建JSON?

您设置的值不正确
ngModel
设置值,您将其设置为
animal.value
,在本例中,该值是字符串lion。相反,它应该是:

<md-select ng-model="context">
    <md-option ng-repeat="animal in animals" value="{{animal}}"  aria-label="{{animal.name}}">{{animal.name}}</md-option>
</md-select>
<div described-type flex="70" contextscope="context"></div>

{{animal.name}

您设置的值不正确
ngModel
设置值,您将其设置为
animal.value
,在本例中,该值是字符串lion。相反,它应该是:

<md-select ng-model="context">
    <md-option ng-repeat="animal in animals" value="{{animal}}"  aria-label="{{animal.name}}">{{animal.name}}</md-option>
</md-select>
<div described-type flex="70" contextscope="context"></div>

{{animal.name}
<md-select ng-model="context">
    <md-option ng-repeat="animal in animals" value="{{animal}}"  aria-label="{{animal.name}}">{{animal.name}}</md-option>
</md-select>
<div described-type flex="70" contextscope="context"></div>