I am attempting to centralize my show/hide functionality for fields in one object (like vm.foo
) that contains key-value pairs. For example, I could add another pair like 1502: true
to hide a field with the key 1502
.
Is there a way to pass variables from the controller to be used in hideExpression
?
Here is a link to a small example where an item is not hidden even though the hideExpression
property is set to true:
http://jsbin.com/rorocitoqi/edit?html,js,output
Below is a snippet where it seems like hideExpression
is not getting the value from vm.foo[bar]
, but when I check with console.log
, the value is stored in vm.foo
. If anyone could provide guidance since I am new to formly, thank you :)
vm.foo = {
1000: true,
1021: false,
3204: true
};
var bar = 1000;
console.log(vm.foo[bar]);
{
key: 'text',
type: 'checkbox',
templateOptions: {
label: 'Hidden box'
},
hideExpression: 'vm.foo[bar]'
}