1
我在我的项目中使用了Siyfion's typeahead directive。Angular typeahead:观察数据集更改
我在控制器做的是这样的:
$http({method: 'GET', 'url': CONFIG.SOMEURL})
.success(function(data, status, headers , config){
if(status==200)
{
$scope.objects = data;
for(i=0; i < $scope.objects.length; i++){
$scope.allObjects.push($scope.objects[i].name);
}
console.log($scope.allObjects);
$scope.dataSet = {
name : 'objs',
local : $scope.allObjects
};
我得到“对象”的数组作为JSON从django
视图。但问题是在我的HTML模板:
<input type="text" class='sfTypeahead' datasets='dataSet' ng-model='testname' />
由于dataSet
最初是空的,而异步调用正在取得我得到一个错误:
TypeError: Cannot read property 'name' of undefined
有没有一种方法,如果我能请在dataSet
或datasets
中查找更改,以便在阵列allObjects
获得填充后,DOM可能会刷新?
任何人都可以提出什么可以在这里完成
只需使用http://angular-ui.github.io/bootstrap/#/typeahead,而不是像这里描述的那样与promise一起工作nativelly:http://stackoverflow.com/a/15930592/1418796 –
它会支持bs3 ?我目前正在使用bs3。 –
是的,它应该与BS3没有问题 –