ngx-contextmenu icon indicating copy to clipboard operation
ngx-contextmenu copied to clipboard

[visible] with negative value

Open elementalTIMING opened this issue 7 years ago • 1 comments

As far as I understood the [visible] get a function that returns true or false. Is there any way to invert the result?

For example: I have two different menu items. The one shall be shown when a variable value is true and the other value shall be hidden - and vice versa.

The only working solution I found is to have two different functions to call - but this is a bit "strange". Is there any other way to do this?

elementalTIMING avatar Dec 12 '18 18:12 elementalTIMING

Not really any other way.

You could theoretically have a function return a function like this:

[visible]="isVisible(true)"
isVisible(oppositeDay: boolean) {
  return () => {
    if(oppositeDay) {
      return false;
    } else {
      return true;
    }
  }
}

isaacplmann avatar Dec 12 '18 18:12 isaacplmann