在AngularJSAngularJS如何選擇並在頁面加載
目標初始化函數:我怎樣才能得到所有類別(按鈕)加以強調和初始化頁面加載或刷新(如可能使用NG-init或NG-選項)
控制器
$scope.selectCategory = function(newCategory) {
$scope.bottomValue = newCategory;
selectedCategory = newCategory;
$scope.selectedPage = 1;
}
$scope.categoryFilterFn = function(product) {
return selectedCategory == null ||
product.category == selectedCategory;
}
$scope.getCategoryClass = function(category) {
return selectedCategory == category ? productListActiveClass : "";
}
$scope.getCategory = function(category) {
return categorySelected == category;
}
HTML
<a ng-click="selectCategory()" class="btn btn-block btn-default btn-lg" style="margin-bottom:6px">All Categories</a>
<a ng-repeat="item in data.products | filter:{edition: data.editions[whichEdition].name}| filter:approved=true | orderBy:itemOrder:direction | orderBy:'-category' | unique:'category' " ng-click="selectCategory(item)" class=" btn btn-block btn-default btn-lg"
ng-class="getCategoryClass(item)">
{{item}}
</a>
你的意思是**要突出顯示並初始化**,你能詳細說明一下嗎? – Sravan