angular-resize-event icon indicating copy to clipboard operation
angular-resize-event copied to clipboard

Event is not assignable to parameter of type ResizedEvent

Open vpeacock opened this issue 2 years ago • 3 comments

<mat-sidenav-content [ngStyle]="{'margin-left.px': contentMargin}">
        <div class="content mat-elevation-z8"  (resized)="onResized($event)">
            <!-- Main content here! -->
            <router-outlet></router-outlet>
        </div>
        <app-scroll-top></app-scroll-top>
    </mat-sidenav-content>

When using this directive in my code, I get the following error:

(parameter) $event: Event Argument of type 'Event' is not assignable to parameter of type 'ResizedEvent'. Type 'Event' is missing the following properties from type 'ResizedEvent': newRect, isFirstngtsc(2345) sidenav.component.ts(15, 24): Error occurs in the template of component SideNavComponent.

This is my method:

public onResized(event: ResizedEvent): void { this.width = Math.round(event.newRect.width); this.height = Math.round(event.newRect.height); console.log(width${this.width}, height${this.height}); }

vpeacock avatar Feb 10 '23 12:02 vpeacock

You forgot to import AngularResizeEventModule.

hakimio avatar Feb 23 '23 10:02 hakimio

I have the same problem and i have import AngularResizeEventModule

MkeniniZaatout avatar Mar 14 '23 13:03 MkeniniZaatout

Is it possible that you have a standalone component and you have imported AngularResizeEventModule in the .ts file, but not in the component's imports: [...] field? I.e.

@Component({
  selector: 'app-my-component',
  standalone: true,
  imports: [AngularResizeEventModule],

andreimatei avatar Jun 27 '23 19:06 andreimatei