我有2个组成部分。我正在尝试从嵌入式组件中获取价值。
这是我的代码
<div *ngFor="let category of categories">
<div *ngIf="documents" class="wrapper ui-g">
<h3 class="category">Explore my {{category}}</h3>
<div *ngFor="let doc of getDocumentsByCategory(category)" class="ui-g-3 ui-lg-3 ui-md-4 ui-md-5">
<app-benefit-document-card [document]="doc" (download)="onDocumentDownload($event)"></app-benefit-document-card>
</div>
</div>
</div>
我现在正在尝试从app-benefit-document-card>中获取一个值。我需要{{document.name}}值。
<div class="card-footer">
<div class="action-container">
<h5 class="name">{{ document.name }}</h5>
<button class="download" (click)="onDownloadUpload()">
<img src="../../../../../assets/icons/right-arrow.png" />
</button>
</div>
</div>
此后,我可以下载最终目标文件
onDocumentDownload(docName: string) {
console.log(docName);
this._loader.start();
this._documentsService.downloadBenefitFile(docName).subscribe((resp: any) => {
const blob = new Blob([resp], {type: 'application/pdf'});
var downloadURL = window.URL.createObjectURL(resp);
var link = document.createElement('a');
link.href = downloadURL;
link.download = docName;
link.click();
this._loader.stop();
}, (error) => {
this._loader.stop();
this._errorService.openErrorPopup('Document downloading failed.');
});
}
请帮助我。我目前无法正确显示该值,并且无法定义。