ng-tags-input autocomplete应该通过静态对象数组生成标签

时间:2017-01-24 07:33:37

标签: angularjs ng-tags-input

我在AngularJS 1中使用 ng-tags-input 作为国家/地区列表。我不想使用 $ http.get()来获取标签。我有一个静态的对象数组,我想在标签中使用它。

1 个答案:

答案 0 :(得分:1)

在加载函数中使用promise angular服务:

$q(function (resolve, reject) {
   resolve($scope.myArray);
}

此:

<auto-complete source="loadTags()"></auto-complete>

将是:

$scope.loadTags = function () {
    return $q(function (resolve, reject) {
       resolve($scope.myArray);
    };
};

$q创建了一个承诺,而您的插件就是这样。

不要忘记在您的依赖项中包含$q