How can I disable the router.navigate
or the link, based on a status?
If the status is a "No" then i can't type the link to edit the Materials?
HTML
<button type="button" (click)="onEditMaterial(material.id)">Edit </button>
TS
onEditMaterial(material_id) {
this.router.navigate(['materials', material_id, 'edit']);
}
<button [attr.disable]="status === 'No'">click me</button>
.status
is a string in your angular component.<button [disable]="status === 'No'">click me</button>
syntax.Edit:
disable
attribute is a HTML5 attribute used for<input> , <button>
etc. You can make it look nicer for better UX with some css as well like this:button:disabled {cursor: not-allowed;}
Edit: another way is something like this