本文介绍了标签集prevents表更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个过滤器的工作表:

HTML(刚刚修改过滤网使用)

HTML (Just modified the filter usage)

<!doctype html>
<html ng-app="plunker">
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.js"></script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.10.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>

<div ng-controller="TabsDemoCtrl">
  <tabset>
     <tab heading="broken filter">
     <form class="form-inline" role="form">
          <select id="okFilterbox" ng-model="okFilterBool">
                 <option>nothing</option>
                     <option>all</option>
            </select>
      </form>
      <p>{{okFilterBool}}</p>
      <div>
        <table>
          <tr ng-repeat="item in items | filterItem:okFilterBool">
            <td>{{item.name}}</td>
          </tr>
        </table>
      </div>
    </tab>

    <tab heading="tab2">
    </tab>


</div>
  </body>
</html>

JS(改变了过滤器定义,以一个新的'角'过滤器的方式)

JS (Changed the way the filter is defined to make a new 'Angular' filter)

angular.module('plunker', ['ui.bootstrap']);
var TabsDemoCtrl = function ($scope) {

  $scope.okFilterBool = "all";

  $scope.items = [
    { name: 'A'},
    { name: 'B'},
    { name: 'C'}
  ];

};

angular.module("plunker").filter("filterItem", function(){
  return function(array, okFilterBool){
        if(okFilterBool == "all"){ return array; }
          return [];
    }
})

这篇关于标签集prevents表更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 23:29