在主要字段中写入应该显示子字段组!!!,但只显示兄弟字段!!! '儿童'中的'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 Bin here。 有什么想法吗?
答案 0 :(得分:1)
孩子的hideExpression
命令基本上可以在以下
hideExpression: '!model.main'
这可能是 ,因为它无论如何直接指向实际元素的键,而不管父键。当然,这仅适用于这种fieldGroup
设置,并且正常!model.parent.main
适用于其他sibling
元素。这真的很奇怪。
以下是working code
另请查看此link。
这里child2
元素在填充child1
后启用。这也遵循类似的模式,在fieldGroup中,所有引用都直接由model.keyname_for_the_field
。