@HostListener('window:resize', ['$event'])
@HostBinding('class.blur') isBlur = false;
onResize(event?) {
this.size = window.innerWidth - 50;
}
this code can occur error like "ctx.isBlur is not a function"
but
@HostBinding('class.blur') isBlur = false;
@HostListener('window:resize', ['$event'])
onResize(event?) {
this.size = window.innerWidth - 50;
}
this code works well... I don't know why...
As I expect , isBlur = false; is not defined before receive resize event.
Because @HostListener expects a function to handle and you give it a property.
Also the two pieces of code you posted are very different.
In the following piece of code you decorate the setfunction of the isBlur to also set the class of the element
Behind the scenes its something like this:
While the method decoration
is something like: