为什么我只有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>
在角度中心:
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中是12个元素以及更多...
Elements in suggest 带元素的数组($ 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 :(得分: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>