![](/img/trans.png)
[英]how to pass selected value from dropdown to another dropdown in next page
[英]How to pass the value selected from dropdown in contextscope in Angularjs?
我有一個下拉列表
$scope.animals = [
{value:'lion', name:'lion', description: 'lion'},
{value:'cat', name:'cat', description: 'cat'},
{value:'dog', name:'dog', description: 'dog'},
];
我想將從dropdown中選擇的值作為contextscope傳遞給另一個指令。 例如
<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>
在describe-type指令中,我正在添加描述
<input ng-model="context.description" name="context.description">
我收到以下錯誤:“無法在字符串'lion'上創建屬性'描述'”
我想要的JSON格式是
"lion" : {
"description": "wild animal"
}
如何解決錯誤並創建JSON?
你設置的值不正確。 ngModel
設置為value,您設置為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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.