angular-formio
Version:
Form.io Angular JSON Form Renderer ========================== This library serves as a Dynamic JSON Powered Form rendering library for [Angular](https://angular.io). This works by providing a JSON schema to a ```<formio>``` Angular component, where that f
35 lines (30 loc) • 1.03 kB
text/typescript
import { Component, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import Prism from 'prismjs';
export class BuilderComponent implements AfterViewInit {
jsonElement?: ElementRef;
codeElement?: ElementRef;
public form: Object = {
components: []
};
onChange(event) {
this.jsonElement.nativeElement.innerHTML = '';
this.jsonElement.nativeElement.appendChild(document.createTextNode(JSON.stringify(event.form, null, 4)));
}
ngAfterViewInit() {
let formattedCode = Prism.highlight(`import { Component, ElementRef, ViewChild } from '@angular/core';
export class BuilderComponent {
jsonElement?: ElementRef;
public form: Object = {components: []};
onChange(event) {
console.log(event.form);
}
}`, Prism.languages.javascript, 'javascript');
this.codeElement.nativeElement.innerHTML = formattedCode;
}
}