0

Need to toggle one table row based on if condition not working.

If status id none I need to open a form in popup but if status is done popup shouldn't open.

<ng-container *ngFor="let person of personList | 
        searchFilter:searchValue;index as i">
    <tr *ngIf="person.status == 'none'" 
            data-toggle="modal" data-target="#personModal" 
            (click)="function(person.id)">
        <tr *ngIf="person.status == 'done'" >
            <td>Place</td>
            <td>Job</td>
        </tr>
    </tr>
</ng-container>

When I tried this solution the row is not displaying in the table list

5
  • It may help to add the typescript component class, so that anyone offering help can use the variables you are using, and it will be easy for them. Commented Mar 3, 2022 at 8:38
  • it is just an html, angular think i guess nothing related to script. there is some issue while am using two tr tag for one table row! Commented Mar 3, 2022 at 8:43
  • You are not closing the second <tr> tag, is it a typo? Commented Mar 3, 2022 at 8:51
  • what i find is you do not close second <tr> after second </td> Commented Mar 3, 2022 at 8:53
  • There should be one tr at a time based on the condition, one opening and closing tr (one row) Commented Mar 3, 2022 at 11:22

1 Answer 1

1

Probably you should do something like this:

<ng-container *ngFor="let person of personList | searchFilter:searchValue;index as i">
  <tr *ngIf="person.status == 'none'" data-toggle="modal" data-target="#personModal" 
      (click)="someFunction(person.id)">
    <td>Place</td>
    <td>Job</td>
  </tr>
  <tr *ngIf="person.status == 'done'" >
    <td>Place</td>
    <td>Job</td>
  </tr>
</ng-container>

But it's important to see your TypeScript code. You should make a Stackblitz example.

Sign up to request clarification or add additional context in comments.

1 Comment

let me check and will get back, Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.