我有一个带过滤器的工作台: http://plnkr.co/edit/WnV7OUplcLHVOKbeTrSw?p=preview
将其包装在tabset中后,它将停止工作(过滤器仍然更新): http://plnkr.co/edit/8uw2UhSC59txms5X563L?p=preview
但在我更新之前,它适用于旧版本: http://plnkr.co/edit/eJvYtpc3efkydsQy8caL?p=preview
(角度1.0.8 + bootstrap 2.0.3 + angular-ui-bootstrap-0.6.0)
为什么它在更新后停止工作?
答案 0 :(得分:1)
http://plnkr.co/edit/70sLuA4gltgxhwTE0XT1
HTML(刚修改过滤器用法)
<!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(更改了定义过滤器以创建新的'Angular'过滤器的方式)
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 [];
}
})