Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event is not assignable to parameter of type ResizedEvent #98

Open
vpeacock opened this issue Feb 10, 2023 · 3 comments
Open

Event is not assignable to parameter of type ResizedEvent #98

vpeacock opened this issue Feb 10, 2023 · 3 comments

Comments

@vpeacock
Copy link

<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}); }

@hakimio
Copy link

hakimio commented Feb 23, 2023

You forgot to import AngularResizeEventModule.

@MkeniniZaatout
Copy link

I have the same problem and i have import AngularResizeEventModule

@andreimatei
Copy link

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],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants