如何在Angular中以架构形式使用getProperty?

问题描述 投票:2回答:1
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;
  }

这是获取架构属性的代码:我想获取小部件中primitiveAutocomplete中的associateAutocompleteunitId

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

两者都返回undefined,但是当我写这篇文章时:

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

它返回其属性

我该怎么办?

angular angular7 angular-schema-form
1个回答
0
投票

您可以使用它:

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

或使用此方法:

searchProperty('your prop')
© www.soinside.com 2019 - 2024. All rights reserved.