私は、電話の録音をブラウズしてダウンロードするためのアプリケーションを作成しています。Angular 2でファイルをダウンロードするにはどうすればよいですか?
このアプリケーションの一部には、記録と関連情報を表示する* ngForが設定されたテーブルがあります。テーブルの各行には、ダウンロード用の記録にマークするためのチェックボックスもあります。私は、私が使用しているテストmp3sへのリンクをconsole.logにすることができるようになりましたが、実際に上記mp3のダウンロードをどのようにトリガーするのか分かりません。
これは、Typescriptを使用してjQueryを使用せずに行うことができます。
<table>
<thead>
<tr>
<th>
<input type="checkbox" [checked]="isAllChecked()" (change)="checkAll($event)"> </th>
<th>Date</th>
<th>Time</th>
<th>Duration</th>
<th>Calling Number</th>
<th>Called Number</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr *ngFor="let entry of recordingsList">
<td>
<input type="checkbox" [(ngModel)]="entry.isSelected"> </td>
<td>{{entry.date}}</td>
<td>{{entry.time}}</td>
<td>{{entry.duration}}</td>
<td>{{entry.callingNumber}}</td>
<td>{{entry.calledNumber}}</td>
<td>
<button (click)="openPlayer(entry)" class="play-button"><i class="material-icons">play_arrow</i></button>
</td>
</tr>
</tbody>
</table>
-
// Download selected recordings
downloadSelected() {
let isSelected = this.recordingsList.filter(x => x.isSelected);
isSelected.forEach(x => console.log(x.audio));
}
-
どのような援助が大幅に高く評価されています。
[アンカー要素](https: //developer.mozilla.org/en/docs/Web/HTML/Element/a)には 'download'属性があります。 –
@PavelStaselun タグのダウンロード属性を知っています。しかし、私はそれが私のユースケースにどのように適用できるのか分かりません。 –