我正在将 Sweet Alert 2 与 Angular 7 一起使用,并且我正在尝试显示动态表格。
Json:
[
{
"name": "Steve",
"age": 23
},
{
"name": "John",
"age": 30
},
{
"name": "Daniel",
"age": 18
}
]
我尝试使用 *ngFor 但不幸的是,它不起作用。
Swal({
position: 'center',
type: 'info',
title: `Class Information`,
html: `<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr *ngFor="let person of persons">
<td>{{person.name}}</td>
<td>{{person.age}}</td>
</tr>
</table>`,
});
我正在尝试显示我自己的组件。
Swal({
position: 'center',
type: 'info',
title: `Class Information`,
html: `<class-component [inputClassInformation]="classInformationJson"></class-component>`
});
这不太有效。
最佳答案
您需要使用 ngx-sweetalert2 for Angular 7 来显示动态表格
<swal title="Fill the form, rapidly">
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr *ngFor="let person of persons">
<td>{{person.name}}</td>
<td>{{person.age}}</td>
</tr>
</table>
</swal>
关于javascript - Angular 7 Sweet Alert显示动态表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55139651/