Angularjs.undefined不是由“未定义”引起的函数;track-by-;陈述
Angularjs. undefined is not a function caused by "track by" statement
我有一个日期数组,必须在选择标签中显示它们
视图:
<select id="select" name="select" class="form-control"
ng-model="files.options.fechaIngreso"
ng-change="files.fechaIngresoChanged()"
ng-options="date.item for date in files.dates track by date.id">
</select>
控制器:
var self = this, data = 4;
self.dates = [];
for (var i =data; i >= 0; i--) {
var historicalDate = moment().subtract(i, 'days').format("DD/MM/YYYY");
var obj = {
item: historicalDate,
id: i
};
self.dates.push( obj );
}
得到了这个错误:
TypeError: undefined is not a function
at render (file:///android_asset/www/lib/angular/angular.js:26098:24)
at Scope.$digest (file:///android_asset/www/lib/angular/angular.js:14358:36)
at file:///android_asset/www/lib/angular/angular.js:14505:26
at completeOutstandingRequest (file:///android_asset/www/lib/angular/angular.js:4924:10)
at file:///android_asset/www/lib/angular/angular.js:5312:7
访问.prop("已选择",选项已选择)时执行失败
(file:///android_asset/www/lib/angular/angular.js:26098:24)
(element = optionTemplate.clone())
.val(option.id)
.prop('selected', option.selected)
.attr('selected', option.selected)
.prop('label', option.label)
.text(option.label);
这个案例也不起作用
<select id="select" name="select" class="form-control"
ng-model="files.options.fechaIngreso"
ng-change="files.fechaIngresoChanged()"
ng-options="date for date in files.dates track by date">
</select>
var self = this, data = 4;
self.dates = [];
for (var i = data; i >= 0; i--) {
var historicalDate = moment().subtract(i, 'days').format("DD/MM/YYYY");
self.dates.push( historicalDate );
}
具有相同的错误
我找到了一个解决方案,不是最佳实践的解决方案,而是一个实用的
<option ng-repeat="date in files.dates" ng-selected="date == files.options.fechaIngreso" value="{{date}}">{{date}}</option>
相关文章:
- 为什么“;未定义的“;在JavaScript中结束循环
- 要求未定义JS回调参数
- 如何检查管道中未定义的项目
- TypeError:无法读取属性'推'未定义的JavaScript
- $window.ga在AngularJS事件中未定义
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 无法获取属性'selectedIndex'的未定义引用或null引用
- 如何消除代码中的未定义和其他问题
- 未捕获的ReferenceError:$未定义
- this.router在AngularJS 2中未定义
- 未捕获的类型错误:无法读取属性'删除'的未定义
- 节点fs.stat名称未定义
- 尝试在PHP中回显输入文本时出现未定义的索引错误
- Jquery未定义函数正在停止其他操作
- AngularJS指令出错-无法读取属性'编译'的未定义
- 这.SOMETHING 总是返回未定义的 - extjs
- 无法获取属性'Id'使用Knockout.js的未定义或空引用API
- Wordpress中带有JQuery Accordion的未定义匿名函数
- Angularjs.undefined不是由“未定义”引起的函数;track-by-;陈述