1

I use angular 4 how can I disable the <a> element with a condition doing something like this [disabled]="!f.form.valid"

<a class="btn btn-primary btn-lg disabled" 
        href="https://mailtrap.io/inboxes/354346/messages" 
        target="_blank" (click)=f.form.reset() > Verify your Email Now</a>

If you suggest to just use the link button so I want to konw how to add target="_blank"

ConnorsFan
  • 70,558
  • 13
  • 122
  • 146
AVA
  • 43
  • 1
  • 7

1 Answers1

1

Credits to styles to this excellent post in css-tricks.

.isDisabled {
  color: currentColor;
  cursor: not-allowed;
  pointer-events: none
  opacity: 0.5;
  text-decoration: none;
}

<a [ngClass]="{'isDisabled':condition}"
   class="btn btn-primary btn-lg disabled" 
   href="https://mailtrap.io/inboxes/354346/messages" 
   target="_blank" (click)=f.form.reset() > Verify your Email Now</a>
Luillyfe
  • 6,183
  • 8
  • 36
  • 46