我有这个HTML:
<select ng-model="group.newCriterionType">
<option ng-repeat="type in group.availableTypes" value="{{type}}" ng-selected="$first">{{type}}</option>
</select>
此模型代码(使用jresig的Class
迷你库)
var FilterGroup = Class.extend({
className: 'FilterGroup',
widgetType: 'group',
init: function(name) {
this.name = name;
this.availableTypes = FilterTypes;
this.newCriterionType = this.availableTypes[0];
this.updateAvailableTypes();
},
});
但是,我仍然在我的选择中得到一个空元素。根据我迄今为止在SO上看到的所有答案,这显然是当您的模型值包含不正确的值时的行为。但是:
console.log
语句中添加了检查值availableTypes
正在设置任何线索都非常感激。
詹姆斯