加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 如何使orderby过滤器工作数组的字符串?

发布时间:2020-12-17 09:09:17 所属栏目:安全 来源:网络整理
导读:这里是不工作的代码:Demo: http://jsfiddle.net/8dt94/63/ div ng-controller="MyCtrl" input type="text" ng-model="searchText" / ul ng-repeat="strVal in arrVal|orderBy|filter:searchText" li{{strVal}}/li /ul/divvar app=angular.module('myApp',[
这里是不工作的代码:Demo: http://jsfiddle.net/8dt94/63/
<div ng-controller="MyCtrl">    
    <input type="text" ng-model="searchText" />
  <ul ng-repeat="strVal in arrVal|orderBy|filter:searchText" >
      <li>{{strVal}}</li>
  </ul>
</div>

var app=angular.module('myApp',[]);
app.controller('MyCtrl',function ($scope,$filter) {
  $scope.arrVal = ['one','two','three','four','five','six'];  
});
您可以通过方法排序,以便可以使用toString方法
<ul ng-repeat="strVal in arrVal | orderBy:'toString()' | filter:searchText">

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读