isaacplmann / ngx-contextmenu

An Angular component to show a context menu on an arbitrary component
MIT License
248 stars 91 forks source link

Angular 8 : working but got an error (a setTimeoutis probably missing somewhere ?) #168

Open paulalbertdev opened 5 years ago

paulalbertdev commented 5 years ago

Describe the bug Context menu is working, but I've still got an error in the dev console :

ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'contextMenu: undefined'. Current value: 'contextMenu: [object Object]'.

To Reproduce Made a stackblitz (take a look at the console) based on your examples https://stackblitz.com/edit/ngx-contextmenu-example-p3cmlw?file=src%2Fapp%2Fapp.component.ts

Expected behavior This should not throw an error

paulalbertdev commented 5 years ago

Just discovered that angular execution is broken when this error occurs , some other things that should happen after won't. So, I think this bug is blocking...

paulalbertdev commented 5 years ago

I was a bit desperate and started to read every issues reported here and found this one (with a totally different problem) https://github.com/isaacplmann/ngx-contextmenu/issues/150 BUT they suggested to add #basicMenu to the context-menu tag, ANNNNND BINGO ! It Works ! You should maybe consider to update the template in your documentation ( https://github.com/isaacplmann/ngx-contextmenu )

lalosh commented 5 years ago

It works for me after I change this line in component.xxx.ts

  @ViewChild(ContextMenuComponent, { static: false }) public basicMenu: ContextMenuComponent;

to

  @ViewChild(ContextMenuComponent, { static: true }) public basicMenu: ContextMenuComponent;