设置Ng-options默认值

时间:2014-11-11 02:55:39

标签: json angularjs

如何设置ng-options默认值...

这是我的ng-option指令:

ng-options="val as val for val in ticket_group.splits"

1 个答案:

答案 0 :(得分:0)

使用ng-init

<select ng-init="myModel = ticket_group.splits[0]" ng-model="myModel" ng-options="val as val for val in ticket_group.splits"></select>

或在控制器中设置myModel值,

$scope.myModel = ticket_group.splits[0]; // ticket_group.splits[1]; ticket_group.splits[2]; .. or what u need

demo