First custom Dynamic Form Module generation

This commit is contained in:
Sebastian Seedorf
2017-05-19 13:01:19 +02:00
parent 01205b16b9
commit a5fdfa32d2
12 changed files with 665 additions and 131 deletions

View 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();
}
}