Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'ion-tab' is not a known element

Trying to use ion-tabs and ion-tab, I can't figure what I am missing
An I am surely missing something obvious to have this :

'ion-tab' is not a known element

My page.html is :

<ion-tabs>
    <ion-tab tab="makuuchi">
        <ion-header translucent>
            <ion-toolbar>
                <ion-title>Makuuchi</ion-title>
            </ion-toolbar>
        </ion-header>
        <ion-content fullscreen class="ion-padding">
            <h1>Makuuchi</h1>
        </ion-content>
    </ion-tab>
    <ion-tab-bar slot="top">
        <ion-tab-button tab="makuuchi">
            <ion-label>Makuuchi</ion-label>
            <ion-icon name="people"></ion-icon>
        </ion-tab-button>
        <ion-tab-button tab="juryo">
            <ion-label>Juryo</ion-label>
            <ion-icon name="people"></ion-icon>
        </ion-tab-button>
    </ion-tab-bar>
</ion-tabs>

ion-tab-bar and ion-tabs are fine. The page is diplayed correctly once I remove ion-tab

My package.json's dependencies

"dependencies": {
    "@angular/common": "^7.2.2",
    "@angular/core": "^7.2.2",
    "@angular/forms": "^7.2.2",
    "@angular/http": "^7.2.2",
    "@angular/platform-browser": "^7.2.2",
    "@angular/platform-browser-dynamic": "^7.2.2",
    "@angular/router": "^7.2.2",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.1.0",
    "core-js": "^2.5.4",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.29"
  },

Project was generated with ionic cli

Ionic:
   Ionic CLI                     : 5.0.2 (/home/christophe/.nvm/versions/node/v8.10.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.5.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1
Utility:
   cordova-res : not installed
   native-run  : not installed
System:
   NodeJS : v8.10.0 (/home/christophe/.nvm/versions/node/v8.10.0/bin/node)
   npm    : 6.9.0
   OS     : Linux 4.18

My module.ts

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes)
  ],
  declarations: [RikishisPage]
})
export class RikishisPageModule {}

ion-tabs are found here : node_modules/@ionic/angular/dist/directives/navigation/ion-tabs.d.ts
ion-tab is not present
I am currently looking for a solution to force loading of ion-tab

Thanks for your help

like image 417
Christ-OFF Avatar asked Jun 14 '19 23:06

Christ-OFF


3 Answers

try replacing ion-tab with ion-tab-bar, so your code will be as below.

source here

    <ion-tabs>
        <ion-tab-bar tab="makuuchi">
            <ion-header translucent>
                <ion-toolbar>
                    <ion-title>Makuuchi</ion-title>
                </ion-toolbar>
            </ion-header>
            <ion-content fullscreen class="ion-padding">
                <h1>Makuuchi</h1>
            </ion-content>
        </ion-tab-bar>
        <ion-tab-bar slot="top">
            <ion-tab-button tab="makuuchi">
                <ion-label>Makuuchi</ion-label>
                <ion-icon name="people"></ion-icon>
            </ion-tab-button>
            <ion-tab-button tab="juryo">
                <ion-label>Juryo</ion-label>
                <ion-icon name="people"></ion-icon>
            </ion-tab-button>
        </ion-tab-bar>
    </ion-tabs>

tested in local, view is being displayed and you should keep routing in place.

like image 166
Mateen Avatar answered Nov 15 '22 21:11

Mateen


As per my understanding your question, I strongly believe that you are missing ionic module inside your module. So I would suggest you add them.

@NgModule({
  declarations: [
//add component declaration
],
  imports: [
    IonicModule //add ionic module here
  ]
})
like image 36
ram12393 Avatar answered Nov 15 '22 23:11

ram12393


I answer my own question : ion-tab doesn't exist in Typescript.
Sample code on the tabs ui component uses ion-tab only when in javascript !

like image 5
Christ-OFF Avatar answered Nov 15 '22 23:11

Christ-OFF