1

I am using angularfire2 in my ionic 3 project to fetch data from firebase database. I am making my tabs using a for loop. Now problem is that it is not selecting the default tab.I need to click myself to view page. Here is my code.

tabs.html

<ion-content>
   <ion-tabs selectedIndex="2" >
       <ion-tab *ngFor="let tab of category|async" [root]="tabPage" tabTitle="{{tab.name}}"></ion-tab>
   </ion-tabs>
</ion-content>

tabs.ts

categoryRef: AngularFireList<any>;
category: Observable<any>;

@ViewChild('myTabs') tabRef: Tabs;
constructor(public db: AngularFireDatabase) {
    this.categoryRef = this.db.list('/category');
    this.category = this.categoryRef.snapshotChanges().map(changes => {
        return changes.map(c => ({ key: c.payload.key, ...c.payload.val()}));
    });
    // this.tabRef.select(2) ;
}
Azam Alvi
  • 6,918
  • 8
  • 62
  • 89

1 Answers1

0

try this:

<ion-content>
   <ion-tabs *ngIf="category|async">
       <ion-tab *ngFor="let tab of category|async" [root]="tabPage" tabTitle="{{tab.name}}"></ion-tab>
   </ion-tabs>
</ion-content>