我正在處理按鈕中包含的一些Angular選項卡。由於某些原因,select函數在被按下時沒有被調用。所以我認爲這個問題必須在html中。我在問題可能出現的地方提供了兩套代碼。調用時不會輸入角度ng-click函數
HTML代碼
<ul>
<li class="navigation-button" role="presentation" ng-class="{active:isSelected(1)}">
<button class="btn-lg btn-primary" ng-click="select(1)" aria-controls="home" role="tab">Home</button>
</li>
<li class="navigation-button" role="presentation" ng-class="{active:isSelected(2)}">
<button class="btn-lg btn-primary" ng-click="select(2)" aria-controls="savings options" role="tab">Savings Options</button>
</li>
<li class="navigation-button" role="presentation" ng-class="{active:isSelected(3)}">
<button class="btn-lg btn-primary" ng-click="select(3)" aria-controls="checking option" role="tab">Checking Options</button>
</li>
<li class="navigation-button" role="presentation" ng-class="{active:isSelected(4)}">
<button class="btn-lg btn-primary" ng-click="select(4)" aria-controls="credit cards" role="tab">Credit Cards</button>
</li>
<li class="navigation-button" role="presentation" ng-class="{active:isSelected(5)}">
<button class="btn-lg btn-primary" ng-click="select(5)" aria-controls="loans" role="tab">Loans</button>
</li>
<li class="navigation-button" role="presentation" ng-class="{active:isSelected(6)}">
<button class="btn-lg btn-primary" ng-click="select(6)" aria-controls="sign in" role="tab">Sign In</button>
</li>
</ul>
角功能
$scope.select = function(setTab) {
$scope.tab = setTab;
if (setTab === 2) {
$scope.filtText = "Savings";
}
else if (setTab === 3) {
$scope.filtText = "Checking";
}
else if (setTab === 4) {
$scope.filtText = "Credit";
}
else if (setTab === 5) {
$scope.filtText = "Loan";
}
else if (setTab === 6) {
$scope.filtText = "Sign";
}
else {
$scope.filtText = "Bank";
}
};
嘗試用012納克點擊元素而不是按鈕.. – Manish
正確的控制器下? – ochi
你的意思是複製粘貼到李並刪除舊的或不同的東西? 納克控制器= 「navController作爲navCtrl」 .controller( 'navController',[ '$範圍',函數($範圍){ –