微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用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.jb51.cc/angularjs/141183.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐