Skip to content
This repository was archived by the owner on Oct 10, 2018. It is now read-only.

Commit 2979626

Browse files
committed
chore: model first
1 parent 4b98b62 commit 2979626

File tree

13 files changed

+52
-51
lines changed

13 files changed

+52
-51
lines changed

src/app/demo/demo.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<nz-sf
22
[schema]="schema"
3+
[(model)]="model"
34
[actions]="actions" (change)="value=$event.value"></nz-sf>
45

6+
<p>
7+
{{ model | json }}
8+
</p>
9+
510
<p>
611
{{ value | json }}
712
</p>

src/app/demo/demo.component.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export class DemoComponent {
1818
}
1919
};
2020

21+
model: any = {
22+
id: 1,
23+
name: 'test',
24+
age: 10
25+
};
26+
2127
schema = {
2228
debug: true,
2329
properties: {
@@ -30,32 +36,25 @@ export class DemoComponent {
3036
},
3137
minLength: 3
3238
},
33-
password: {
34-
type: 'string',
35-
title: '密码',
36-
widget: {
37-
type: 'password',
38-
placeholder: '请输入密码,且6位以上'
39-
},
40-
minLength: 6
39+
'menu': {
40+
'type': 'object',
41+
title: 'test',
42+
'properties': {
43+
'id': {
44+
'type': 'string',
45+
'title': '菜单',
46+
span_label: 5,
47+
span_control: 5
48+
},
49+
'title': {
50+
'type': 'string',
51+
'title': '标题',
52+
span_label: 5,
53+
span_control: 5
54+
}
55+
}
4156
}
4257
},
43-
required: ['name', 'password'],
44-
button: {
45-
items: [
46-
{
47-
label: '登录',
48-
id: 'send',
49-
submit: true,
50-
popconfirm: true,
51-
poptitle: '123'
52-
},
53-
{
54-
label: '重置',
55-
id: 'reset'
56-
}
57-
]
58-
}
5958
};
6059

6160
constructor(private msg: NzMessageService) {

src/app/example/basic/basic.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ <h3>水平布局:</h3>
44
<ng-template #body>
55
<nz-sf layout="horizontal"
66
[schema]="DATA.horizontal.schema"
7-
[model]="DATA.horizontal.model"
8-
[actions]="actions" (change)="DATA.horizontal.value=$event.value"></nz-sf>
7+
[(model)]="DATA.horizontal.model"
8+
[actions]="actions"></nz-sf>
99
</ng-template>
1010
</nz-card>
1111
<h3>垂直布局:</h3>
1212
<nz-card>
1313
<ng-template #body>
1414
<nz-sf layout="vertical"
1515
[schema]="DATA.vertical.schema"
16-
[model]="DATA.vertical.model"
17-
[actions]="actions" (change)="DATA.vertical.value=$event.value"></nz-sf>
16+
[(model)]="DATA.vertical.model"
17+
[actions]="actions"></nz-sf>
1818
</ng-template>
1919
</nz-card>
2020
<h3>内联布局:</h3>
2121
<nz-card>
2222
<ng-template #body>
2323
<nz-sf layout="inline"
2424
[schema]="DATA.inline.schema"
25-
[model]="DATA.inline.model"
26-
[actions]="actions" (change)="DATA.inline.value=$event.value"></nz-sf>
25+
[(model)]="DATA.inline.model"
26+
[actions]="actions"></nz-sf>
2727
</ng-template>
2828
</nz-card>
2929
<div ace-editor

src/app/example/basic/basic.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ export class ExampleBasicComponent {
2020
DATA: any = {
2121
horizontal: {
2222
code: '' + require('!!raw-loader!../../schema/login-schema.json'),
23-
value: {},
2423
model: { email: 'cipchk@qq.com' }
2524
},
2625
vertical: {
2726
code: '' + require('!!raw-loader!../../schema/login-schema.json'),
28-
value: {},
2927
model: { email: 'cipchk@qq.com' }
3028
},
3129
inline: {
3230
code: '' + require('!!raw-loader!../../schema/login-schema.json'),
33-
value: {},
3431
model: { email: 'cipchk@qq.com' }
3532
}
3633
};

src/app/example/conditional/conditional.component.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ <h1>条件表单</h1>
22
<p>通过配置 Schema 的 <code>visibleIf</code> 属性根据条件表达式显示表单,例如:根据不同登录方式渲染不同表单</p>
33
<nz-sf
44
[schema]="DATA.schema"
5-
[model]="DATA.model"
6-
[actions]="actions"
7-
(change)="DATA.value=$event.value"></nz-sf>
8-
{{ DATA.value | json }}
5+
[(model)]="DATA.model"
6+
[actions]="actions"></nz-sf>
7+
{{ DATA.model | json }}
98
<markdown [data]="demo"></markdown>

src/app/example/fixed/demo.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { NzMessageService } from 'ng-zorro-antd';
66
@Component({
77
selector: 'app-example-fixed',
88
template: `
9-
<nz-sf [schema]="schema" [model]="model" [actions]="actions" (change)="value=$event.value">
9+
<nz-sf [schema]="schema" [(model)]="model" [actions]="actions">
1010
<ng-template nz-template="custom" let-control let-schema>
1111
<nz-input [formControl]="control">
1212
<ng-template #addOnBefore>http://</ng-template>
@@ -17,7 +17,6 @@ import { NzMessageService } from 'ng-zorro-antd';
1717
`
1818
})
1919
export class ExampleFixedComponent {
20-
value: any;
2120
schema: SFSchema = {
2221
debug: true,
2322
span_label_fixed: 100,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<h1>不规则列布局</h1>
22
<p>通过配置 Schema 的 <code>span_label_fixed</code><code>grid</code> 属性构建不同列刚需布局。</p>
33
<p>布局技巧:利用24格栅格系统先划分列数,再配合指定字段属性 <code>grid</code> 参数来指定字段渲染格数;始终保持一行 <code>24</code> 格。</p>
4-
<nz-sf [schema]="schema" [model]="model" [actions]="actions" (change)="value=$event.value">
4+
<nz-sf [schema]="schema" [(model)]="model" [actions]="actions">
55
<ng-template nz-template="custom" let-control let-schema>
66
<nz-input [formControl]="control">
77
<ng-template #addOnBefore>http://</ng-template>
88
<ng-template #addOnAfter>.com</ng-template>
99
</nz-input>
1010
</ng-template>
1111
</nz-sf>
12+
model: {{ model | json }}
1213
<markdown [data]="demo"></markdown>

src/app/example/fixed/fixed.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { NzMessageService } from 'ng-zorro-antd';
77
templateUrl: './fixed.component.html'
88
})
99
export class ExampleFixedComponent {
10-
value: any;
1110
schema: SFSchema = {
1211
debug: true,
1312
span_label_fixed: 100,

src/app/example/sort/sort.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ <h1>调整顺序</h1>
22
<p>通过配置 Schema 的 <code>order</code> 数组属性可以按需求改变表单渲染顺序。<strong>注:</strong> 若指定顺序则必须包含所有属性。</p>
33
<nz-sf
44
[schema]="DATA.schema"
5-
[model]="DATA.model"
6-
(change)="DATA.value=$event.value"></nz-sf>
7-
{{ DATA.value | json }}
5+
[model]="DATA.model"></nz-sf>
6+
model: {{ DATA.model | json }}
87
<markdown [data]="demo"></markdown>

src/app/example/sort/sort.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { SFSchema, PropertyGroup, FormProperty } from 'nz-schema-form';
88
})
99
export class ExampleSortComponent {
1010
DATA: any = {
11-
value: {},
1211
model: { name: 'cipchk' }
1312
};
1413

0 commit comments

Comments
 (0)