File tree Expand file tree Collapse file tree 1 file changed +24
-22
lines changed Expand file tree Collapse file tree 1 file changed +24
-22
lines changed Original file line number Diff line number Diff line change 3030To use the library in your project, follow these steps:
3131
3232``` shell
33- npm i @angular/material
34- npm i @angular/flex-layout
35- npm i @angular/cdk
3633npm i @dashjoin/json-schema-form
3734```
3835
@@ -78,35 +75,40 @@ A small sample component:
7875
7976` ` ` typescript
8077import { Component } from '@angular/core';
81- import { Schema } from '@dashjoin/json-schema-form/lib/schema';
78+ import { State } from '@dashjoin/json-schema-form';
79+ import { FormArray } from '@angular/forms';
8280
8381@Component({
8482 selector: 'app-root',
8583 template: `
86- < lib - json - schema - form [(value )]= " value" [schema ]= " schema" [label ]= " schema.title" > </lib -json -schema -form >
87- <pre >{{print ()}}< pre >
84+ < lib - json - schema - form [state ]= " state" > </lib -json -schema -form >
8885 `
8986})
9087export class AppComponent {
9188
92- schema: Schema = {
93- type: 'array',
94- items: {
95- type: 'object',
96- properties: {
97- name: { type: 'string' },
98- bday: { type: 'string', widget: 'date' }
89+ state: State = {
90+ schema: {
91+ type: 'array',
92+ items: {
93+ type: 'object',
94+ properties: {
95+ name: { type: 'string' },
96+ bday: { type: 'string', widget: 'date' }
97+ }
9998 }
100- }
99+ },
100+ value: any = [{
101+ name: 'Joe',
102+ bday: '2018-09-09T22:00:00.000Z'
103+ }];
104+ name: 'myform',
105+ control: new FormArray([])
101106 };
102-
103- value: any = [{
104- name: 'Joe',
105- bday: '2018-09-09T22:00:00.000Z'
106- }];
107-
108- print(): string {
109- return JSON.stringify(this.value, null, 2);
107+
108+ foo() {
109+ this.state.control.valueChanges.subscribe(res => {
110+ console.log(res);
111+ })
110112 }
111113}
112114` ` `
You can’t perform that action at this time.
0 commit comments