我使用角度j在选择框中填充选项。选项已填充,但每个选项的值属性会自动填充。怎么能控制得那么?即我需要将名称作为其值。 这是我的代码
<select ng-model="plist" ng-options="item.name for item in items"><option value="">--Select Item--</option></select>
$scope.items = [
{name:'black', shade:'dark'},
{name:'white', shade:'light'},
{name:'red', shade:'dark'},
{name:'blue', shade:'dark'},
{name:'yellow', shade:'light'}
];
答案 0 :(得分:0)
将对象存储在ng-model中:
<select ng-model="plist"
ng-options="item as item.name for item in items">
...
仅存储ng-model中的值:
<select ng-model="plist"
ng-options="item.name as item.name for item in items">
...