我如何创建一个angular2 json模式形式的字段部分?
我使用的是https://github.com/dschnelldavis/angular2-json-schema-form,我的表单HTML是:
<json-schema-form
[schema]="schema"
(onSubmit)="exampleOnSubmitFn($event)">
</json-schema-form>
我的schema
是:
this.schema = {
type: "object",
properties: {
CCN: {
required: true,
type: "number",
minimum: 1000000000,
maximum: 99999999999999999999
},
Quarter: {
type: 'string',
required: true,
enum: ['Q1', 'Q2', 'Q3', 'Q4']
},
Year: {
type: 'string',
required: true,
enum: ['2018', '2019', '2020']
},
covered_medi: {
title: "Covered by Medicare/Medicaid",
type: "number",
required: true
},
covered_private: {
title: "Covered by private insurance",
type: "number",
required: true
},
Uninsured: {
type: "number",
required: true
},
}
}
我希望Quarter
和Year
分开。 我尝试使用layout
属性:
this.layout = [{
type: "fieldset",
title: "Reporting Period",
items: [{
key: "Quarter"
}, {
key: "Year"
}]
}]
但这似乎不起作用。
如果您已安装并实例化提供程序。 唯一可能失败的是架构,示例或回调,测试时使用空的测试。
TS
@Component({...})
export class MyComponent {
public schema: any = {...}
public onSubmit(event) {...}
... }
HTML
<json-schema-form
[schema]="schema"
(onSubmit)="onSubmit($event)">
</json-schema-form>
在这个例子中,把每个属性中所需的。
链接地址: http://www.djcxy.com/p/41417.html上一篇: How can I create a section of fields with angular2 json schema form?
下一篇: Ordering objects by foreignkey field and not foreignkey count