Home > front end >  disable on condition angular table
disable on condition angular table

Time:03-10

I have a table in my html file how do I disable onClick function on condition startdate> currentdate

        <ng-container matColumnDef="d">
          <th
            mat-header-cell
            *matHeaderCellDef
          >
            Start Date
          </th>
          <td
            mat-cell
            *matCellDef="let w"
            (click)="display = false; create(false, w)"
            title="Cannot start"
          >
            {{ w.startDate }}
          </td>
        </ng-container>

and suppose I want to show "cannot start" title only when startdate>current date how could I do that

CodePudding user response:

Put a condition in your click logic

.html

(click)="clicked(w)"

.ts

clicked(w) {
    if (w.startdate > new Date()) {
        this.display = false;
        this.create(false, w)
    }
}
  • Related