ngx-formly-tabs is an Angular module that adds Components that enable flexible tab use for @ngx-formly.
npm install ngx-formly-tabsbash
npm install ngx-formly-tabs --save
`
#### 2. Import the FormlyTabsModule:
`typescript
import {NgModule} from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {FormlyModule} from '@ngx-formly/core';
import {FormlyBootstrapModule} from '@ngx-formly/bootstrap';
import {FormlyTabsModule} from 'ngx-formly-tabs';
@NgModule({
imports: [
...,
ReactiveFormsModule,
FormlyModule.forRoot(),
FormlyBootstrapModule,
FormlyTabsModule
],
})
export class AppModule {}
`
#### 3. Use the tabset type together with tab types/wrappers within the form config of your component:
`typescript
import {Component} from '@angular/core';
import {FormGroup} from '@angular/forms';
import {FormlyFieldConfig} from '@ngx-formly/core';
@Component({
selector: 'app',
template:
,
})
export class AppComponent {
model = { email: 'email@gmail.com' };
fields: FormlyFieldConfig[] = [
{
type: 'tabset',
fieldGroup: [
{
type: 'tab',
templateOptions: {
tabTitle: 'Primary'
},
fieldGroup: [
{
key: 'name',
type: 'input',
templateOptions: {
label: 'Name'
}
}
]
},
{
wrappers: ['tab'],
templateOptions: {
tabTitle: 'Secondary'
},
fieldGroup: [
{
key: 'hobby',
type: 'input',
templateOptions: {
label: 'Hobby'
}
}
]
}
]
}
];
submit(model) {
console.log(model);
}
}
``