Angular 7 Sweet alert show динамический стол - PullRequest
2 голосов
/ 13 марта 2019

Я использую 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>`
    });

Это также не работает.

Моя цельотображается следующее всплывающее окно: enter image description here

1 Ответ

2 голосов
/ 13 марта 2019

вам нужно использовать ngx-sweetalert2 для Angular 7, чтобы показать динамическую таблицу show

NGX-sweetalert2

<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>
...