如何使用angular2 json架构表单创建一段字段?

前端之家收集整理的这篇文章主要介绍了如何使用angular2 json架构表单创建一段字段?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 https://github.com/dschnelldavis/angular2-json-schema-form,我的表单HTML是:
<json-schema-form
[schema]="schema"
(onSubmit)="exampleOnSubmitFn($event)">
</json-schema-form>

我的架构是:

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',enum: ['2018','2019','2020']  
    },covered_medi: {
      title: "Covered by Medicare/Medicaid",required: true
    },covered_private: {
      title: "Covered by private insurance",Uninsured: {
      type: "number",}
}

我希望Quarter和Year在一个单独的部分.我尝试使用layout属性

this.layout = [{
  type: "fieldset",title: "Reporting Period",items: [{
    key: "Quarter"
  },{
    key: "Year"
  }]
}]

但这似乎行不通.

如果您有 installed and instantiated the provider.唯一可能失败的是schema,examples或回调,使用空的测试.

TS

@Component({...})
export class MyComponent {

   public schema: any = {...}
   public onSubmit(event) {...}
   ... }

HTML

<json-schema-form
  [schema]="schema"
  (onSubmit)="onSubmit($event)">
</json-schema-form>

在这个example中,把所需的每个属性.

原文链接:https://www.f2er.com/angularjs/141183.html

猜你在找的Angularjs相关文章