我有一个使用Angularjs和Ionic-v1的应用程序。
我有一个通用的标题栏,我有两个图标(一个用于Tab1,一个用于Tab2)。在屏幕底部,我有两个选项卡(Tab1和Tab2)。
当我在Tab1中时,我想要显示Tab1 only.And的图标当我在Tab2中时,我想仅显示Tab2的图标。
<div ng-click="menu.changeLayout()">
<a class="icon_one" ng-if="!grid"></a>
<a class="icon_change" ng-if="grid"></a>
<a class="icon_one_test" ng-if="!grid1"></a>
<a class="icon_change_test" ng-if="grid1"></a>
</div>
In this line <a class="icon_one_test" ng-if="!grid1"></a> ,Is there any way to hide icon_one and icon_change class?Or is there any other way to do this.角码
$rootScope.grid=false;
$rootScope.grid1=false;
menu.changeLayout=function(){
console.log("current state"+$state.current.name);
if($state.current.name=='menu.tab1'){
console.log('tab1');
$rootScope.grid=!$rootScope.grid;
}
else if($state.current.name=='menu.tab2'){
console.log('tab2');
$rootScope.grid1=!$rootScope.grid1;
}
}如何实现this.Can谁请帮我如何做到这一点。
发布于 2017-12-29 23:14:50
使用ng-class根据条件设置类。
<div ng-click="menu.changeLayout()">
<a ng-class="{icon_one: !grid , icon_change: grid}" ></a>
<a ng-class="{icon_one_test: !grid , icon_change_test: grid}" ></a>
</div>在条件中还隐藏未选中的选项卡。
if($state.current.name=='menu.tab1'){
console.log('tab1');
$rootScope.grid= true;
$rootScope.grid1 = false;
}
else if($state.current.name=='menu.tab2'){
console.log('tab2');
$rootScope.grid1=true;
$rootScope.grid= false;
}https://stackoverflow.com/questions/48020325
复制相似问题