First custom Dynamic Form Module generation
This commit is contained in:
26
src/app/modules/dyn-form/dyn-question.component.ts
Normal file
26
src/app/modules/dyn-form/dyn-question.component.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {QuestionInterface} from './types/question.interface';
|
||||
import {FormGroup} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'dyn-question',
|
||||
template: `
|
||||
<div [ngSwitch]="question.type" [formGroup]="form">
|
||||
<label [for]="question.properties.key">{{question.properties.label}}</label>
|
||||
<tag-input *ngSwitchCase="'flag'"
|
||||
[formControlName]="question.properties.key" [id]="question.properties.key"
|
||||
[items]="question.properties.options" [nullable]="question.constraints.optional"
|
||||
(ngModelChange)="change()"></tag-input>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class DynQuestionComponent {
|
||||
@Input() question: QuestionInterface;
|
||||
@Input() type: "'insert'|'update'|'delete'|'view'";
|
||||
@Input() form: FormGroup;
|
||||
@Output() onChange: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
change() {
|
||||
this.onChange.emit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user