tabset prevents table update

2019-09-18 05:46发布

I have a working table with a filter: http://plnkr.co/edit/WnV7OUplcLHVOKbeTrSw?p=preview

After wrapping it in a tabset it stops working (the filter is still updated): http://plnkr.co/edit/8uw2UhSC59txms5X563L?p=preview

But it worked with old versions before I updated: http://plnkr.co/edit/eJvYtpc3efkydsQy8caL?p=preview

(angular 1.0.8 + bootstrap 2.0.3 + angular-ui-bootstrap-0.6.0)

Why did it stop working after the update?

1条回答
Fickle 薄情
2楼-- · 2019-09-18 06:25

http://plnkr.co/edit/70sLuA4gltgxhwTE0XT1

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 (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 [];
    }
})
查看更多
登录 后发表回答