我正在尝试将下拉值设置为javascript代码的默认值,但我无法设置它。
我的代码jsFiddle
sudo updatedb; locate MySymbols.woff
JavaScript代码
<div ng-controller="csrClrt">
<div ng:repeat="(key, item) in items track by $index">
<md-input-container>
<label>Face Style:</label>
<md-select ng-model="item.style" ng-change="f_style()" ng-model-options="{trackBy: '$value.id'}">
<md-option ng-value="user" ng:repeat="user in styles">{{user.name}}</md-option>
</md-select>
</md-input-container>
<div>
Id:{{item.style.id}}
<br/> Want to Display Name {{item.style.name}}
</div>
</div>
</div>
答案 0 :(得分:1)
您尚未正确创建items
对象且无需ng:repeat="(key, item) in items track by $index"
视图的
<div ng-controller="csrClrt">
<md-input-container>
<label>Face Style:</label>
<md-select ng-model="items.style" ng-change="f_style()" ng-model-options="{trackBy: '$value.id'}">
<md-option ng-value="user" ng:repeat="user in styles">{{user.name}}</md-option>
</md-select>
</md-input-container>
<div>
{{items.style}}
</div>
</div>
控制器
$scope.items = {
style: {
id: 1
}
};