How would you control size of an element on resize of the window in a component?

Technology CommunityCategory: AngularHow would you control size of an element on resize of the window in a component?
VietMX Staff asked 3 years ago

@HostListener lets you listen for events on the host element or component.

This is a function decorator that accepts an event name as an argument. When that event gets fired on the host element it calls the associated function.

Consider:

@HostListener('window:resize', ['$event'])
onResize(event: any) {
    this.calculateBodyHeight();
}