if (url.indexOf('master/confirm-account') > 0) {
$scope.accountInfo = 'Confirm Account';
$scope.page = 'confirm_account';
$scope.activeTab = true;
} else if (url.indexOf('master/master-profile') > 0) {
$scope.accountInfo = 'Confirm Account';
$scope.page = 'master_profile';
$scope.activeTab = true;
} else {
$scope.accountInfo = 'Create Account';
}
<div ng-class = "{'process-step' : true, '({{page}}=='confirm_account') ? 'active-tab' : ' '}" >
如何添加process-step和active-tab类 如果条件匹配则预期结果变为那样
答案 0 :(得分:1)
ng-class的工作方式与
类似{'add_this_class' : (if_this_expression_is_true)}
而不是其他方式。
试试这个
<div class="process-step" ng-class="{'active-tab' : (page =='confirm_account') }">
答案 1 :(得分:0)
看到类匹配逻辑的复杂性,你可以采用第二种方式来实现ng-class
**内部HTML **
<div class="process-step" ng-class="ctrl.getPageBasedClass()">
内部控制器
var self.getPageBasedClass = function(){
var yourClassNameAsString = // your logic for class name
return yourClassNameAsString;
}