2016-03-01 55 views
1

在主字段中寫入應該顯示子域fieldGroup !!!,但只顯示兄弟域!!! '孩子'中的'hideExpression'不起作用??? !!!角形,嵌套形式,hideExpression不起作用

在這個例子中,當字段沒有嵌套時,它們的'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。 有什麼想法?

回答

0

哇,這花了很長時間。

爲孩子的hideExpression命令實際上踢以下

hideExpression: '!model.main' 

這是可能,因爲它在某種程度上直接指實際要素的關鍵,不論父母的key.Ofcourse,這僅適用於這種fieldGroup設置,正常!model.parent.main對其他設備也適用,如sibling元素的情況。這真的很奇怪。

這裏是working code

也有看看這個link。 這裏child2元素在child1被填充之後被啓用。這也遵循類似的模式,其中在字段組中,所有的引用直接由model.keyname_for_the_field引用。

+1

感謝您的幫助@ckniffen! –