2016-07-04 3 views
1

なぜ私はオートコンプリートに10項目しかありませんか? 私はケーキのビューのコードを持っている:テキストエリアオートコンプリートanglejsのみ10要素

<?php $leadersOptions = array(
      array('id' => '1', 'text' => '1'), 
      array('id' => '2', 'text' => '2'), 
      array('id' => '3', 'text' => '3'), 
      array('id' => '4', 'text' => '4'), 
      array('id' => '5', 'text' => '5'), 
      array('id' => '6', 'text' => '6'), 
      array('id' => '7', 'text' => '7'), 
      array('id' => '8', 'text' => '8'), 
      array('id' => '9', 'text' => '9'), 
      array('id' => '10', 'text' => '10'), 
      array('id' => '11', 'text' => '11'), 
      array('id' => '12', 'text' => '12') 
); ?> 
<?php $encoded = json_encode($leadersOptions); ?> 

<div ng-controller="TagsCtrl"> 
    <textarea ng-init="leadersOptions = <?php echo empty($leadersOptions) ? '[]' :h($encoded); ?>; leaders = <?php echo empty($projectUser) ? '[]' :h(json_encode($projectUser)); ?>" class="ng-hide" name="data[Project][leader_id]"> 
     {{leaders}} 
    </textarea> 

    <label>Dodaj leadera</label> 
    <tags-input ng-model="leaders" placeholder="Kliknij aby wybrać" add-on-paste="true" add-on-enter="false" add-on-space="false" add-on-comma="false" add-on-blur="false"> 
     <auto-complete source="loadTags()" load-on-focus="true" load-on-down-arrow="true" load-on-empty="true"> 
     </auto-complete> 
    </tags-input> 
</div> 

と角CTR中:

app.controller('TagsCtrl', function ($scope, $window, $sce, $http, $rootScope) { 

    $scope.loadTags = function (query, tags) { 
     return $scope.leadersOptions; 
    } 
    $scope.loadContractors = function (query, tags) { 
     return $scope.contractorsOptions; 
    } 
    $scope.loadUserCategory = function() { 
     return $scope.categoriesOptions; 
    } 
}); 

そして、まだそれは10個の要素を提案したが$ leadersOptionsには

Elements in suggest ... 12要素とよりです 要素を持つ配列($ leadersOptions):

<?php $leadersOptions = array (
    array('id' => '1', 'text' => '1'), 
    array('id' => '2', 'text' => '2'), 
    array('id' => '3', 'text' => '3'), 
    array('id' => '4', 'text' => '4'), 
    array('id' => '5', 'text' => '5'), 
    array('id' => '6', 'text' => '6'), 
    array('id' => '7', 'text' => '7'), 
    array('id' => '8', 'text' => '8'), 
    array('id' => '9', 'text' => '9'), 
    array('id' => '10', 'text' => '10'), 
    array('id' => '11', 'text' => '11'), 
    array('id' => '12', 'text' => '12') 
);?> 

誰も助けてくれますか?私はangularJSでうまくいきません...ありがとう。

+0

時間($エンコード)機能コードがどのように見えるとは何ですか? – mtamma

+1

できるだけ問題をバックエンド*または*フロントエンドの問題のいずれかに分離する場合は、コードを[mcve]にしてください。 – Jeroen

+0

@mtamma - htmlspecialcharsの便利なメソッドです。このメソッドはこの場合何もしません。:( –

答えて

1

解決済み。自動補完では、 'max-results-to-show = "99"'を追加しました。

今のコードは次のようになります。

<auto-complete source="loadTags()" load-on-focus="true" max-results-to-show="99" load-on-down-arrow="true" load-on-empty="true"></auto-complete> 
関連する問題