What I would do is set a property on each row to indicate if it's being edited as shown below:
https://stackblitz.com/edit/angular-usbhmd
The code for people that do not want to click that.
Html
<table class="table table-hover">
<thead>
<tr>
<th>Domain</th>
<th>Registered Date</th>
<th>Action</th>
</tr>
<tr *ngFor="let domain of domains; let i = index">
<td>
<span *ngIf="!domain.editable">{{domain.name}}</span>
<input type="text" class="form-control" [(ngModel)]="domain.name" *ngIf="domain.editable"/>
</td>
<td>
<span *ngIf="!domain.editable">{{domain.reg_date}}</span>
<input type="date" class="form-control" [(ngModel)]="domain.reg_date" *ngIf="domain.editable"/>
</td>
<td><button class="btn btn-primary" (click)="editDomain(domain)">Edit</button></td>
</tr>
</thead>
<tbody>
</tbody>
</table>
Component
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
domains = [];
isVisible : boolean = false;
constructor(){
this.domains = [
{
"_id" : "12323vdfvd234",
"name" : "sixlogs.com",
"reg_date" : "2018-04-04",
"editable": false
},
{
"_id" : "12323vdfvd234",
"name" : "avanza.com",
"reg_date" : "2019-04-04",
"editable": false
},
{
"_id" : "12323vdfvd234",
"name" : "tps.com",
"reg_date" : "2018-04-04",
"editable": false
},
{
"_id" : "12323vdfvd234",
"name" : "utf.com",
"reg_date" : "2019-04-04",
"editable": false
}
]
}
editDomain(domain: any){
domain.editable = !domain.editable;
}
}
As you can see I have added the editable property to the domains array, that gets set for the object when the editDomain get's triggered by the button click
event. With the editable property you can then changed your view to display inputs for each row.