angular-formly,嵌套形式,hideExpression不起作用

angular-formly, nested form, hideExpression does not work

写在主字段应该显示子字段Group !!!,但只显示兄弟字段!!! 'hideExpression' 在 'child' 中不起作用???!!!

在这个例子中,字段没有嵌套响应它的 'hideExpression' 和嵌套组没有,当它们相同时。

vm.fields = [
      {
        key: 'sibling',
        type: 'input',
        templateOptions: {
          required: true,
          type: 'text',
          label: 'Sibling'
        },
        hideExpression: '!model.parent.main'
      },
      {
        key: 'parent',
        wrapper: 'panel',
        templateOptions: { label: 'Parent' },
        fieldGroup: [
          {
          key: 'main',
          type: 'input',
          templateOptions: {
            required: true,
            type: 'text',
            label: 'Main'
          }
        },
      {
        key: 'child',
        wrapper: 'panel',
        templateOptions: { label: 'Child' },
        hideExpression: '!model.parent.main', //why it does not work ???!!!!!!!!
        fieldGroup: [
          {
          key: 'child1',
          type: 'input',
          templateOptions: {
            required: true,
            type: 'text',
            label: 'Child1'
          }
        },
        {
          key: 'child2',
          type: 'input',
          templateOptions: {
            required: true,
            type: 'number',
            label: 'Child2'
          }
        }]
      }]
      }
    ];

The nested group remains hidden.

JS 斌 here。 有什么想法吗?

哇,这花了很长时间。

child 的 hideExpression 命令基本上会在以下

中启动
hideExpression: '!model.main'

这是可能因为它以某种方式直接引用实际元素的键,与parent key.Ofcourse无关,这仅适用于这种 fieldGroup 设置和正常的 !model.parent.main 可以像 sibling 元素一样对其他设置起作用。这真的很奇怪。

这是working code

也看看这个link。 这里 child2 元素在 child1 之后启用 filled.This 也遵循类似的模式,其中在 fieldGroup 中,所有引用都直接由 model.keyname_for_the_field.