Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs – 在UI bootstrap typeahead中’显示更多结果’大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在UI引导程序中的typeahead中实现显示更多结果@L_618_1@.最初它应该加载5个结果,然后如果结果超过5我想显示一个显示更多结果选项以再次从API加载所有结果(没有限制).

这是我在模板中的预先定义:

<input type="text" name="FullName" id="FullName"
    class="form-control"  autocomplete="false" required="required"
    placeholder="Search by name"
    uib-typeahead="ent as ent.FullName for ent in vm.findEntities($viewvalue)"
    typeahead-popup-template-url="entityPopup.tpl.html"
    typeahead-template-url="popupMatch.tpl.html"
    typeahead-on-SELEct="vm.entitySELEcted($item)"
    ng-model="vm.FullName">

我在父 – 父控制器中有一个变量,其中包含结果的计数. $父.$parent.vm._entity@R_871_10586@lResults.如果该计数超过5,那么我想显示一个显示更多”按钮,该按钮可以加载更多结果并将其填充到预先输入结果中.

我的entityPopup.tpl.html如下:

只是认的一个添加< li>< / li>

<ul class="dropdown-menu" ng-show="isopen() && !moveInProgress" ng-style="{top: position().top+'px',left: position().left+'px'}" style="display: block;" role="listBox" aria-hidden="{{!isopen()}}">
      <li ng-repeat="match in matches track by $index" ng-class="{active: isActive($indeX) }" ng-mouseenter="SELEctActive($indeX)" ng-click="SELEctMatch($indeX)" role="option" id="{{::match.iD}}">
          <div uib-typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
      </li>
      <li ng-show="$parent.$parent.vm._entity@R_871_10586@lResults > 5">SHOW MORE</li>
  </ul>

我的先行函数findEntities()如下:

vm.findEntities = function findEntities(viewValue,limit) {
  return api@R_772_9260@ce.findEntities(viewValue,limit)
    .then(function(matches) {
      vm._entity@R_871_10586@lResults = matches.@R_871_10586@lResults;
      return matches.Results;
    });
  };

api@R_772_9260@ce.findEntities()是一个API函数,它接受一个可选的limit参数并返回$http promise.如果它为null则返回所有结果,否则会限制它们.

我怎么能实现这个?我没有在互联网上找到任何可以指引我走向正确方向的东西.

解决方法

您可以将typeahead包装在自定义指令中,并为uibTypeahead提供 custom popup-template

大佬总结

以上是大佬教程为你收集整理的angularjs – 在UI bootstrap typeahead中’显示更多结果’全部内容,希望文章能够帮你解决angularjs – 在UI bootstrap typeahead中’显示更多结果’所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。