我是使用角度js的新手,我很困惑,我有这样的代码
angular.module("sportStore")
.constant("productListActiveClass", "btn-primary")
.controller("productListCtrl", function($scope, $filter, productListActiveClass) {
var selectedCategory = null;
$scope.selectCategory = function(newCategory) {
selectedCategory = newCategory;
}
$scope.categoryFilterFn = function(product) {
return selectedCategory == null ||
product.category == selectedCategory;
}
$scope.getCategoryClass = function(category) {
return selectedCategory == category ? productListActiveClass : "";
}
});

<div class="panel panel-default row" ng-controller="productListCtrl">
<div class="col-xs-3">
<a ng-click="selectCategory()" class="btn btn-block btn-default btn-lg">Home</a>
<a ng-repeat="item in data.products | orderBy:'category' | unique: 'category'" ng-click="selectCategory(item.category)" class="btn btn-block btn-default btn-lg" ng-class="getCategoryClass(item.category)">
{{item.category}}</a>
</div>
</div>
&#13;
然后当我尝试它时,导致chrome如下:
并在firefox中如下:
有人可以告诉我为什么会这样吗? ng-class在firefox上运行但不在chrome中运行。提前谢谢。
答案 0 :(得分:1)
我发现之前必须清理chrome中的缓存。它现在在chrome中工作。