what i'm trying to do is to have like one place, object (like in this example vm.foo
) with key: value
pairs for showing and hiding my fields. So i could for example just put to my object another pair like: 1502: true
which i could use for example to hide my field with key 1502
If there is any way to pass my variables from controller for hideExpression
to use.
Here is just a link to the same small example where item isn't hidden, although hideExpression
property is set to true
http://jsbin.com/rorocitoqi/edit?html,js,output
Below is just a small snippet, it seems hideExpression
doesn't get my value from vm.foo[bar]
but when i check console.log
value is stored in vm.foo
. If anyone could provide right guideline since i just started with formly, thanks :)
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]'
}
You're misunderstanding how hideExpression
s work. It's a formlyExpression
similar (not exactly the same) as expressionProperties
.
Here's the working example:
{
key: 'text',
type: 'checkbox',
templateOptions: {
label: 'Hidden box'
},
hideExpression: function() { return vm.foo[bar] }
}