angular_code
angular_code

Reputation: 359

How to remove a particular dynamic element from html in angular reactive form

I have created a dynamic reactive form using which I can add or delete fields dynamically, everything is working fine. When I click on the below + sign, I get the result as -

I want to remove the Radio Button (And / Or ) from the last row always like if it's 3 rows, I want only for 1st and 2nd, it should not come up for third. I tried a lot but I am not able to achieve it.

Can someone please help?

Upvotes: 1

Views: 337

Answers (1)

Eliseo
Eliseo

Reputation: 57929

just use in *ngFor, let last=last and a *ngIf="!last" see the docs

<div formArrayName="example"
      *ngFor="let a of exampleForm.get('example').value; 
      let i = index ;
      let last=last;  <!--add the let last=last-->
      trackBy: trackByFn">
   ...
   <div class= "operators" *ngIf="!last">
     ...
   </div>
 </div>

Upvotes: 1

Related Questions