【发布时间】:2018-02-09 01:34:25
【问题描述】:
我制作了在内部使用 Angular UI typeahead 指令的自定义指令,但没有按预期工作。在我的指令模型中,选择时没有更新。有人帮忙吗?为了测试,我使用了静态数组而不是 http 服务。笨蛋HERE.
.directive('httpDictionary', ['$compile', function($compile){
return {
scope: {
},
restrict: 'A',
controllerAs: "dm",
controller: ['$scope', '$http', 'ARRAY', function($scope, $http, ARRAY){
var dm = this;
dm.dict = function(val){
return ARRAY; // for testing only
// return $http.get($scope.dictionaryUrl, { ...
}
}],
link: function(scope, element, attributes, ngModel) {
scope.dictionaryUrl = attributes.httpDictionary;
element.removeAttr('http-dictionary'); // avoid loop
element.attr('uib-typeahead', 'd for d in dm.dict($viewValue)');
$compile(element)(scope);
}
};
}])
【问题讨论】:
标签: angularjs angularjs-directive angular-ui-bootstrap