AngularJS-ng-repeat select选项的默认值

i

我有一个表格,用户需要选择两周的班次类型。我需要为每个单元格设置UNIQUE默认值,例如Day 1: D, Day2:N, etc.我怎样才能做到这一点?

小提琴:https : //jsfiddle.net/fujik8467/axnm0cy9/24/

辛格(Parminder Singh)

您可以使用以下代码:

 <select ng-model="day.selectedShiftType" ng-options="shift as shift.strId for shift in shifts" ng-init="day.selectedShiftType = shifts[0]">

上面将始终选择第一个选项,但是我们可以使用以下代码将其随机化: $scope.GetRandomIndex = function() { return Math.floor((Math.random()*3)+1); }

html代码:

<select ng-model="day.selectedShiftType" ng-options="shift as shift.strId for shift in shifts" ng-init="day.selectedShiftType = shifts[GetRandomIndex()]">

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章