Hi,
my new app (based on the tabs template) can be used by two type of users: suppliers
and customers
.
I’d like that, after the login, the dashboard tabs opens two different pages based on the role of the user.
The two pages are very different so I won’t use the same page.
Which is the best way to do this?
I’m using this solution (tabs.html
and tabs.ts
):
<ion-tabs>
<ion-tab [root]="tab1Root" tabTitle="{{ 'Dashboard' | translate }}" tabIcon="speedometer"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="{{ 'Customers' | translate }}" tabIcon="people"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="{{ 'Products' | translate }}" tabIcon="document"></ion-tab>
</ion-tabs>
import { DashboardPage } from '../dashboard/dashboard';
import { DashboardcustPage } from '../dashboardcust/dashboardcust';
....
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
tab1Root : any;
tab2Root = CustomersPage;
tab3Root = ProductsPage;
constructor(private navCtrl: NavController,
private translate: TranslateService,
private settings:SettingsProvider
) {
console.log("Supplier: ", settings.getIsSupplier());
if (settings.getIsSupplier()){
console.log("Set DashboardPage in tab1Root !!!");
// ????
this.tab1Root = DashboardPage;
} else {
console.log("Set DashboardcustPage in tab1Root !!!");
// ????
this.tab1Root = DashboardcustPage;
}
}
}
It seems to work, but I don’t know if there is a smarter way to do this.
Obviously I do not want to load the content of both pages but only the content of the right one.
Thank you very much.
cld