src/app/pages/users/add/add-user.component.ts
selector | ngx-add-user-component |
styleUrls | add-user.component.scss |
templateUrl | ./add-user.component.html |
Properties |
Methods |
|
constructor(activatedRoute: ActivatedRoute, apiDataProviderService: ApiDataProviderService)
|
|||||||||
Parameters :
|
Private initPageWithConfig | ||||
initPageWithConfig(config: )
|
||||
Parameters :
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
formList |
formList:
|
Type : any
|
Default value : {}
|
objectKeys |
objectKeys:
|
Default value : Object.keys
|
pageTitle |
pageTitle:
|
Type : string
|
Default value : ''
|
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from "@angular/router";
import * as _ from 'lodash';
import {ApiDataProviderService} from "../../../@core/services/api/api-data-provider.service";
@Component({
selector: 'ngx-add-user-component',
styleUrls: ['./add-user.component.scss'],
templateUrl: './add-user.component.html',
})
export class AddUserComponent implements OnInit {
pageTitle: string = '';
formList: any = {}; // title
objectKeys = Object.keys;
constructor(private activatedRoute: ActivatedRoute,
private apiDataProviderService: ApiDataProviderService) {
}
ngOnInit() {
this.initPageWithConfig(_.cloneDeep(this.activatedRoute.snapshot.data));
}
private initPageWithConfig(config): void {
this.pageTitle = config.pageTitle;
Object.keys(config.forms).forEach(FORM_KEY => {
config.forms[FORM_KEY].schema.subscribe(res => {
this.formList[FORM_KEY] = config.forms[FORM_KEY];
this.formList[FORM_KEY].schema = res;
})
});
}
}
<div class="row">
<div class="col-sm-12">
<nb-card>
<nb-card-header>{{pageTitle}}</nb-card-header>
<nb-card-body>
<div class="row">
<div *ngFor="let form of objectKeys(formList)" class="{{formList[form].containerClass}}">
<nb-card>
<nb-card-header>{{formList[form].title}}</nb-card-header>
<nb-card-body>
<sf-form [schema]="formList[form].schema">
</sf-form>
</nb-card-body>
</nb-card>
</div>
</div>
</nb-card-body>
</nb-card>
</div>
</div>