【问题标题】:how to use getProperty in schema-form in Angular?如何在 Angular 中以模式形式使用 getProperty?
【发布时间】:2019-12-31 07:11:53
【问题描述】:
public static get schema(): ISchemaModel {
    const schema = {
      formTitle: 'process-stream-parameter',
      type: 'object',
      readOnly: false,
      properties: {
        name: {
          type: 'string',
          description: 'gl.process-stream-parameter.schema.name',
          widget: '_string',
        },
        processStreamCategoryId: {
          type: 'object',
          description: 'gl.process-stream-parameter.schema.processStreamCategoryId',
          serviceName: 'processStreamCategoryListService',
          widget: '_select',
          help: 'gl.process-stream-parameter.schema.help.processStreamCategoryId',
          titleKey: 'name',
          properties: {
            id: {
              type: 'number'
            },
            title: {
              type: 'string'
            },
            _title: {
              type: 'string'
            }
          }
        },
        unitGroupSelective: {
          type: 'string',
          description: '',
          widget: '_empty',
        },
        unitId: {
          type: 'object',
          description: 'gl.attribute.schema.unitId',
          widget: '_couple-autocomplete',
          properties: {
            id: {
              type: 'number'
            },
            title: {
              type: 'string'
            },
            _title: {
              type: 'string'
            }
          },
          primitiveAutocomplete: {
            serviceName: 'unitGroupListService',
            help: 'gl.attribute.schema.unitGroup',
            description: 'gl.attribute.schema.unitGroup',
            fieldName: 'unitGroupSelective',
            foreignKey: 'title',
            params: {
              titleKey: 'title'
            },
            properties: {
              id: {
                type: 'number'
              },
              title: {
                type: 'string'
              },
              _title: {
                type: 'string'
              }
            },
          },
          associateAutocomplete: {
            serviceName: 'unitListService',
            help: 'gl.attribute.schema.unitId',
            description: 'gl.attribute.schema.unitId',
            fieldName: 'unitSelective',
            methodName: 'units',
            params: {
              titleKey: 'title'
            },
            properties: {
              id: {
                type: 'number'
              },
              title: {
                type: 'string'
              },
              _title: {
                type: 'string'
              }
            },
          }
        },
      },
      required: ['name']
    } as ISchemaModel;
    return schema;
  }

这是我获取架构属性的代码: 我想在我的小部件中获取unitId 中的primitiveAutocompleteassociateAutocomplete

 console.log(this.formProperty.findRoot().getProperty('associateAutocomplete'));

两者都返回undefined,但是当我写这个时:

console.log(this.formProperty.findRoot().getProperty('unitId'));

它返回它的属性

我该怎么办?

【问题讨论】:

    标签: angular angular7 angular-schema-form


    【解决方案1】:

    你可以使用它:

    this.formProperty.findRoot().getProperty('unitId').properties['your prop'].value
    

    或使用此方法:

    searchProperty('your prop')
    

    【讨论】:

      猜你喜欢
      • 2018-04-16
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 2017-06-20
      • 1970-01-01
      • 1970-01-01
      • 2019-11-14
      • 1970-01-01
      相关资源
      最近更新 更多