0

是否可以使用创建自定义自动编译ng-tags-input

我从服务器收到这样的响应:

在此处输入图像描述

这就是我为国家和地址自动完成的方式:

search.data.suggest.country[0].options

这个重新运行的对象数组:

[
    {"text": "Puerto Rico", "score" : "1"}
    ...
]

search.data.adress.country[0].options

这是我的尝试只是为了不工作...

$http.get('http://localhost:3000/api/v1/gym/autocompletion?q=' + query)
    .then(function(search) {
        var deferred = $q.defer();
        console.log(search.data.suggest.country[0].options);
        deferred.resolve(search.data.suggest.country[0].options);

        return deferred.promise;
    });

这将显示错误:

angular.js:13550 TypeError: Cannot read property 'data' of undefined
    at ng-tags-input.min.js:1
    at processQueue (angular.js:15961)
    at angular.js:15977
    at Scope.$eval (angular.js:17229)
    at Scope.$digest (angular.js:17045)
    at Scope.$apply (angular.js:17337)
    at angular.js:19166
    at completeOutstandingRequest (angular.js:5869)
    at angular.js:6145

有什么解决办法吗?

4

0 回答 0