I have an application using Angularjs and Ionic-v1.
I have a common headerbar where i have 2 icons(one for Tab1 and one for Tab2). And in the bottom of the screen i have 2 tabs(Tab1 and Tab2).
When i am in Tab1,i want to show icon for Tab1 only.And when I am in Tab2 i want to show icon for Tab2 only.
<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.
Angular code
$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;
}
}
How to achieve this.Can anyone please help me how to do this.
use
ng-class
to set the classes according to conditions.inside the condition hide the unselected tabs also.