2016-07-05 85 views
1

我試圖顯示帶自動填寫的標籤輸入字段,以便如果用戶在輸入字段中輸入一些文本,則可用標籤在下拉列表中顯示爲建議。一切工作正常至今:ngTagsInput/auto-complete(AngularJS)

<body ng-app="plunker" ng-controller="MainCtrl"> 
    <tags-input ng-model="tags" add-on-paste="true"> 
     <auto-complete source="loadTags($query)"></auto-complete> 
    </tags-input> 
    <p>Model: {{tags}}</p> 
</body> 

AngularJS代碼:

var app = angular.module('plunker', ['ngTagsInput']); 

    app.controller('MainCtrl', function($scope, $http) { 
     $scope.loadTags = function(query) { 
      return $http.get(Routing.generate('my_route_to_json_data')); 
     } 
    }); 

這裏是工作的結果: enter image description here

問題是,當我嘗試添加maxResultsToShow="4"minLength="1"屬性,他們不沒有工作,我仍然得到相同的結果。

<body ng-app="plunker" ng-controller="MainCtrl"> 
    <tags-input ng-model="tags" add-on-paste="true"> 
      <auto-complete maxResultsToShow="4" loadOnEmpty=true minLength="1" source="loadTags($query)"></auto-complete> 
    </tags-input> 
    <p>Model: {{tags}}</p> 
</body> 

任何想法?

回答

2

<auto-complete max-results-to-show="4" load-on-empty="true" min-length="1" source="loadTags($query)">

在角,則必須在JS代碼的HTML標籤和駝峯使用劃線的情況下,它們被自動轉換。