感谢SOF解决我在angularjs和autocomplete中的最后一期问题。 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的任何想法..
答案 0 :(得分:1)
this.item.upload_status
应为scope.item.upload_status