这是我的index.html
<form ng-controller = "emailViewController">
<tags-input placeholder="To" ng-model="select" typeahead="toPerson for toPerson in to | filter:$viewValue" style="width:95%;">
</tags-input>
<br />
<input type="text" placeholder="Subject" style="width:95%;"><br />
<textarea style="width:95%;" rows="10"></textarea>
</form>
emailViewController.js
(function() {
'use strict';
var emailViewController = function (fetchDataService,$scope,$filter) {
var url = 'app/mock/emails.json';
fetchDataService.getContent(url)
.then(function(response){
$scope.emails = response.data;
$scope.to = [];
angular.forEach($scope.emails, function(key, value) {
$scope.to.push(key.to);
})
$scope.loadEmails('Primary');
});
}
angular.module('iisEmail')
.controller ('emailViewController',
['fetchDataService', '$scope','$filter', emailViewController]);
}());
Typeahead在我删除input标签(它是一个属性)并添加tags-input指令之前工作正常。所以,我之前有<input placeholder="To" ng-model="select" typeahead="toPerson for toPerson in to | filter:$viewValue" style="width:95%;">过。现在,我有<tags-input placeholder="To" ng-model="select" typeahead="toPerson for toPerson in to | filter:$viewValue" style="width:95%;">,但它不起作用。
我认为这是因为typeahead仅适用于input tags. 有没有人有关于如何使用的typeahead想法ngTagsInput?
为了避免任何混淆,我想明确一点,我知道如何使用autocompletewith ngTagsInput。我的问题是专门针对我在使用typeaheadwith时遇到的问题ngTagsInput。
这是一个plunker:http ://plnkr.co/edit/B1aV9TLu58a2iGhpTUrN?p=preview
更新
angular-tags我使用代替解决了这个问题ngTagsInput。ngTagsInput不适用于typeahead. 选择的最佳答案很好地解释了为什么会这样。这是解决此问题的 Plunker angular-tags- http://plnkr.co/edit/PaG1k5N37BTOflObnN7K?p=preview