I have 5 tabs
<ion-tabs tabsPlacement="bottom" tabsLayout="icon-top" tabsHighlight="true" color="primary">
<ion-tab [root]="myCardsTabRoot" tabTitle="My Cards" tabIcon="ios-photos"></ion-tab>
<ion-tab [root]="calendarTabRoot" tabTitle="Calendar" tabIcon="calendar"></ion-tab>
<ion-tab [root]="myProfileTabRoot" tabTitle="My Profile" tabIcon="ios-person"></ion-tab>
<ion-tab [root]="searchTabRoot" tabTitle="Search" tabIcon="ios-search"></ion-tab>
<ion-tab [root]="pendingRequestsTabRoot" tabTitle="Follow Req" tabIcon="notifications" tabBadge="{{pendingRequests}}" tabBadgeStyle="danger"></ion-tab>
</ion-tabs>
I want to show last tab only if there is any pending requests, I tried below but still no chance and doesn't show/hide tab when pendingRequests
value is changing,
value of pendingRequests
is changed in ionViewDidEnter()
<div *ngIf="pendingRequests > 0">
<ion-tab [root]="pendingRequestsTabRoot" tabTitle="Follow Req" tabIcon="notifications" tabBadge="{{pendingRequests}}" tabBadgeStyle="danger"></ion-tab>
</div>
and
<ion-tab *ngIf="pendingRequests > 0" [root]="pendingRequestsTabRoot" tabTitle="Follow Req" tabIcon="notifications" tabBadge="{{pendingRequests}}" tabBadgeStyle="danger"></ion-tab>
If I restart app, tabs are displayed correctly based on the value of pendingRequests
the only issue is that when the value is changed tabs doesn't hide/show correspondingly
here is the code for updating pendingRequests
ionViewDidEnter() {
this.refreshPrendingRequests();
}
refreshPrendingRequests() {
this.contactsService.getContactRequestsCount(this.userInfoService.currentProfile.id)
.subscribe(count => this.pendingRequests = count);
}
Update
Based on @Sampath suggestion, I create a plunker for it. The behavior is different than what I have it on my app, but also this one is not working too.
Clicking on top right toolbar button should show/hide tab http://plnkr.co/edit/Cx6Pyr9AihvX66ASed0s?p=preview