Solution 1 :

It isn’t clear what you mean by nodes. But if you want to disable an event handler binding based on a single variable, you could do so by using the ternary operator. Try the following

Controller

export class AppComponent {
  nodes: boolean = true;

  onClick(event) {
    console.log('button clicked');
  }
}

Template

<button (click)="nodes ? onClick(event) : ''">Click me</button>

Problem :

here the enableAddLink function looks like this in the typescript

enableAddLink() {
    this.storyboard.network.addNodeMode = false;
    this.addNodeMode = false;
    this.addLinkMode = !this.addLinkMode;
    this.storyboard.network.addLinkMode = this.addLinkMode;
  }

The links should get created only when nodes exist else I want it to be disabled.

Comments

Comment posted by Cat

Your code doesn’t indicate how we can know whether a node exists. Is there a

Comment posted by DevLoverUmar

Please add some details to let us understand the whole context of problem, otherwise we won’t be able to help you 🙂

Comment posted by Don Lee

We can not help from a little info like that. Please provide more code!

Comment posted by Rishi Khemka

sorry guys, newbie here. But was eventually able to fix my problem using an if condition with the node object. @Cat correct on this one , Umar Farooq and Don, thanks for suggestions !

Comment posted by Rishi Khemka

What you’re saying is correct, had to use the ternary operator and set a condition accordingly. Thanks !

By