My tabs.ts (simpilified) - the data used for the generated tabs using * ngFor is given from the php backend:
import ...
export interface Group {
id: number;
group: string;
};
@Component( {
template: `
<ion-tabs #myTabs selectedIndex="0">
<ion-tab *ngFor="let tab of userGroups" [root]="page" [rootParams]="tab.id" [tabTitle]="tab.group" tabIcon="pulse"></ion-tab>
</ion-tabs>
`
})
export class GroupsTabsPage {
userGroups: Group[];
page: any = TabStudentsPage;
constructor( public app: App, public api: Api, public navParams: NavParams ) {
this.api.getGroupsList()
.subscribe(
data => {
this.userGroups = data;
},
err => {
this.app.getRootNav().push( LoginPage )
}
);
}
}
The result is invisible tabs. But , when you hover over them, the cursor changes to a “hand,” and you can click them. When clicked, the entire tab bar becomes visible, and everything works as expected.
When I used @ViewChild to refer to tab items, the interesting thing is that its length property is always 0 (I checked the ionViewDidLoad event). An attempt to select one of the tabs programmatically also failed - they look like ghosts;)
, * ngFor , * ngFor, , selectedIndex .
? .