просто нужно сохранить выбранную строку в переменной, которую мы затем можем отобразить в HTML
в вашем стекаблике , измените modal-basic.html на:
<code><table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let tableRow of table" (click)="open(content, tableRow)">
<th scope="row">{{tableRow.id}}</th>
<td>{{tableRow.first}}</td>
<td>{{tableRow.last}}</td>
<td>{{tableRow.handle}}</td>
</tr>
</tbody>
</table>
<ng-template #content let-modal>
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">Details</h4>
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
id:<u>{{selectedRow.id}}</u><br>
first:<u>{{selectedRow.first}}</u><br>
last:<u>{{selectedRow.last}}</u><br>
handle:<u>{{selectedRow.handle}}</u>
</div>
</ng-template>
<hr>
<pre>{{closeResult}}
в вашем стекаблице , измените modal-basic.ts на:
import {Component} from '@angular/core';
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'ngbd-modal-basic',
templateUrl: './modal-basic.html'
})
export class NgbdModalBasic {
closeResult: string;
table = [
{
"id": 1,
"first":"Mark",
"last": "Otto",
"handle": "@mdo"
},{
"id": 2,
"first":"Jacob",
"last": "Thornton",
"handle": "@fat"
},{
"id": 3,
"first":"Larry",
"last": "the Bird",
"handle": "@twitter"
}
];
selectedRow;
constructor(private modalService: NgbModal) {}
open(content, tableRow) {
this.modalService.open(content, {ariaLabelledBy: 'modal-basic-title'});
//console.log(tableRow)
this.selectedRow = {id:tableRow.id, first: tableRow.first, last:tableRow.last, handle:tableRow.handle};
}
}