I am trying to observe a change event of a object specific property bound to a custom attribute. I use the bindable
tag for this.
The object
var information = {
name: 'foo',
description: 'bar',
age: 12
};
The element
<div my="info: information;"></div>
The attribute
@customAttribute('my')
export class MyCustomAttribute {
@bindable({
changeHandler: 'change'
})
public info: any;
private change(): void {
console.log('info has changed')
}
}
Above example only fires the change handler once. But I need it to fire every time when one of the properties on the info
object changes. In my use-case it doesn't matter which property changes, I just need to know when a property changes.
Any idea on how to that?
FYI => A different approach would be to create a separate property on the view model (and use bindable tags on that) instead of using the object, but I rather not do that because it would make the plumbing of the attribute tedious in the HTML (because of the amount of properties).
I managed to solve it this way; (thanks to the comment of Marc Scheib)