【发布时间】:2013-09-25 12:32:21
【问题描述】:
感谢 SOF 解决了我在 angularjs 和自动完成方面的最后一个问题。 Angularjs with jquery auto complete not working
现在,我在 ng-repeat 中遇到了相同类型的问题...
在视图中
<tr data-ng-repeat="item in pagedItems">
<td title={{item.name}}>{{item.name}}</td>
<td> <input type=text auto-complete ng-model="item.upload_status">
Upload status: {{item.upload_status}}</td>
<td title={{item.lat}}>{{item.lat}}</td>
<td title={{item.lon}}>{{item.lon}}</td>
</tr>
在指令中
myapp.directive('autoComplete', function(autoCompleteDataService) {
return {
restrict: 'A',
link: function(scope, elem, attr, ctrl) {
elem.autocomplete({
source: autoCompleteDataService.getSource(),
select: function( event, ui ) {
scope.$apply(function() { this.item.upload_status = ui.item.value; });
},
change: function (event, ui) {
if (ui.item === null) {
scope.$apply(function() { scope.foo = null });
}
},
minLength: 2
});
}
};
});
它给出的错误是,
TypeError:无法设置未定义的属性“upload_status”
任何更新 upload_status 的想法表示赞赏..
【问题讨论】:
-
尝试
scope.item.upload_status而不是this.item.upload_status -
Worked CodeHater.. 谢谢..如何研究这个 angularjs.. 很难开始.. 请添加为答案..
-
您可以通过 angularjs.org 提供的教程来清楚地了解基础知识。
标签: javascript jquery angularjs jquery-ui-autocomplete angularjs-ng-repeat