I have a component with an optional '&' binding.
How can I check whether a method was passed into the component through this binding?
assuming that:
bindings: {
onChange: '&?',
}
When I run if (this.onChange)
it always evaluates to an angular wrapper (and thus true):
ƒ (locals) {
return parentGet(scope, locals);
}
I read this post and tried by checking if (this.$attrs.onChange)
, but that doesn't work either. $attrs.onChange
evaluates to:
if (this.$attrs.onChange) {
console.log(this.$attrs.onChange) // $resolve.onChange()
console.log(typeof this.$attrs.onChange); //string
}
What am I doing wrong? Running on Angular 1.5.8