标签:blog io ar color sp java for on div
废话不多说,直接上代码。
function MySelectCtrl($scope) { $scope.Model = [ { id: 10002, MainCategory: ‘男‘, ProductName: ‘水洗T恤‘, ProductColor: ‘黑‘ }, { id: 10004, MainCategory: ‘女‘, ProductName: ‘V领短袖‘, ProductColor: ‘红‘ }, { id: 10006, MainCategory: ‘男‘, ProductName: ‘圆领长袖‘, ProductColor: ‘白‘ }]; $scope.selected = 10002; }
<select ng-model="selected" ng-options="m.id as (m.ProductColor + ‘ - ‘ + m.ProductName) for m in Model"> <option value="">-- 选择一个试试 --</option> </select>
写下这些,希望我这辈子都不要再被angular的默认选中和传值问题干扰了!
AngularJS之ng-options的best practise
标签:blog io ar color sp java for on div
原文地址:http://www.cnblogs.com/xiangmin/p/4120666.html