我正在尝试使用 descargartodo 函数将网格的 idEvento2 值传递给我的按钮,以便按下按钮时可以下载具有相同 ID 的所有文档 我怎么办?
html
<ng-container *ngIf="state$ | async as state">
<lib-modal-container class="bootstrap-wrapper"
[modalTitle]="state.title"
[formType]="state.formType"
[loading]="state.loading"
(dismiss)="handleClose()">
<div class="m-r-12">
<div class="fixed-bottom-buttons text-right">
<button
matTooltip="descargar archivos"
class="mini-icon-button"
mat-flat-button
color="primary"
type="button"
(click)="descargartodo()">
<mat-icon> file_download</mat-icon>
Decargar todo
</button>
<br />
<br />
</div>
<lib-grid variant="list"
emptyRowsMsg="No hay registros"
[loading]="state.gridControlResumen.loading"
[definition]="state.gridControlResumen.definition"
[source]="state.gridControlResumen.source">
<ng-template libTemplate="tpl-accion"
let-data>
<button matTooltip="Ver archivo"
class="mini-icon-button"
mat-icon-button
value="documento"
color="primary"
type="button"
(click)="handleClickVerArchivo($event,data.idEvento,data.documento)" >
<mat-icon>visibility</mat-icon>
</button>
</ng-template>
</lib-grid>
</div>
</lib-modal-container>
</ng-container>
打字稿
descargartodo = (data) => {
const { idEvento: idEvento } = this.store.selectSnapshot(FORM_RESUMEN_SOL_STATE_TOKEN);
this.solicitudesService.descargarSolAgendaWord(idEvento).subscribe(blob => {
CORE_FUNCTIONS.downloadFile(blob, 'agenda.docx');
})
this.solicitudesService.descargarReporteInvitadosWord(idEvento).subscribe(blob => {
CORE_FUNCTIONS.downloadFile(blob, 'invitados.docx');
});
}
handleClickVerArchivo = ($event, data, documento) => {
const idEvento2 = data;
if (documento == "Agenda") {
try {
this.solicitudesService.descargarSolAgendaWord(idEvento2).subscribe(blob => {
CORE_FUNCTIONS.downloadFile(blob, 'agenda.docx');
});
} catch (e) { console.log("hubo un error") }
}
}
我需要将值从 handleClickVerArchivo 传递到 descargartodo
答案 0 :(得分:1)
html
<hello name="{{ name }}"></hello>
<p>
Start editing to see some magic happen :)
</p>
<form novalidate #formIdToPass="ngForm" (ngSubmit)="handleClickVerArchivo(formIdToPass.value)">
<label>ID</label>
<input type="text" name="idToPass" ngModel>
<input type="submit" value="send">
</form>
<p>
{{ descargartodo() }}
</p>
ts
import { Component, VERSION } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular ' + VERSION.major;
idToPass: number;
constructor(){
this.idToPass = 0;
}
descargartodo() {
if (this.idToPass > 0 ){
let data = this.idToPass
console.log(this.idToPass)
return data;
}}
handleClickVerArchivo(data) {
console.log(data)
this.idToPass = data.idToPass
}
}
stackblitz 中的演示