首页 > 解决方案 > 如何聚焦在 ngx-formly 中另一个字段的 fieldGroup 内配置的字段?

问题描述

export class AppComponent {
  form = new FormGroup({});
  model = {
    investments: [{}, {}],
  };
  options: FormlyFormOptions = {};

  fields: FormlyFieldConfig[] = [
    {
      key: 'investments',
      type: 'repeat',
      fieldArray: {
        fieldGroupClassName: 'row',
        templateOptions: {
          btnText: 'Add another investment',
        },
        fieldGroup: [
          {
            type: 'input',
            key: 'investmentName',
            templateOptions: {
              label: 'Name of Investment:',
              required: true,
            },
          }
        ],
      },
    },
  ];

现在将生成 2 个输入字段如何将第二个字段集中在某个方法上?在运行时将字段集中在某些操作上的最佳方法是什么?

标签: angular-formly

解决方案


推荐阅读