Can't get tabs by using <mat-tab-group>
I have installed latest nodejs, angular cli, and angular material but i cant get tabs when i run project in browser
@angular/cli: 1.4.5
node: 8.7.0
os: linux x64
@angular/animations: 4.4.5
@angular/cdk: 2.0.0-beta.12
@angular/common: 4.4.5
@angular/compiler: 4.4.5
@angular/core: 4.4.5
@angular/forms: 4.4.5
@angular/http: 4.4.5
@angular/material: 2.0.0-beta.12
@angular/platform-browser: 4.4.5
@angular/platform-browser-dynamic: 4.4.5
@angular/router: 4.4.5
@angular/cli: 1.4.5
@angular/compiler-cli: 4.4.5
@angular/language-service: 4.4.5
typescript: 2.3.4
Registration component Html
<app-header>
</app-header>
<div class="mainwrap">
<div class="heading">
Registration
</div>
<mat-tab-group>
<mat-tab label="Tab 1">Content 1</mat-tab>
<mat-tab label="Tab 2">Content 2</mat-tab>
</mat-tab-group>
</div>
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { RegistrationComponent } from './registration/registration.component';
import {MatTabsModule} from '@angular/material';
@NgModule({
declarations: [
AppComponent,
HeaderComponent,
RegistrationComponent
],
imports: [
BrowserModule,
MatTabsModule,
RouterModule.forRoot(
[
{
path: '',
redirectTo: 'registration',
pathMatch: 'full'
},
{
path: 'registration',
component: RegistrationComponent
}
])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
I have found my answer after some research
I did not import BrowserAniminationModule
in app.module.ts
due to which i could not use the tabs properly.
I had a problem similar only with mat-tabs, and it appears it was another error that was causing trouble. After resolving other issues (in browser console), the tabs finally appeared !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With