0

I have a table with 4 columns-Name, id, Dept, City and I'm providing both row data and column data as an array from a typescript file and iterating through *ngFor. Here is my piece of code

<tbody>
   <tr *ngFor="let rowData of data | orderBy:convertSorting()">
       <td *ngFor="let column of columns; let idx=index">
            <span *ngIf="idx == 1 && someCondition">
                 <a href="your-target-url">{{rowData[column.columnValue] | format:column.filter}}</a>
            </span>
            <span *ngIf="idx != 1">
                {{rowData[column.columnValue] | format:column.filter}}
            </span>
       </td>
   </tr>
</tbody>

I have provided a hyperlink to all the rows of second column i.e city. I want to make this non-clickable if "someCondition" is false. How do I that?

Protagonist
  • 1,649
  • 7
  • 34
  • 56

1 Answers1

0

Angular2, what is the correct way to disable an anchor element?

a.disabled {
   pointer-events: none;
   cursor: not-allowed; 
}
<a [class.disabled]="!someCondition" href="your-target-url">
Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567