问题描述
我想在单击按钮时将数据从我的组件发送到指令:
这是我的自定义指令:
my.directive.ts:
import {..}
@Directive({
selector: '[descarga-fichero]',})
export class DescargaFicheroSgticDirective {
@Input("descarga-fichero") infoFicheroModel: FicheroModel;
@Output() onEventDirectiveValue = new EventEmitter();
@HostListener('click',['$event']) manejadorDelClick() {
this.descargarFichero();
}
constructor() { }
descargarFichero() {
// some stuff with infoFicheroModel object
}
这是我的组件:
my.component.html
<button [descarga-fichero]="infoFicheroModel"
(click)="compositeInfoFicheroModel()">
Descargar Informe
</button>
我希望当按钮被点击时,接收指令的“infoFicheroModel”对象被填充,但不是之前。发生的情况是,当我单击按钮时,指令的主机侦听器触发,然后“compositeInfoFicheroModel ()”方法触发。我不知道怎么做,当单击按钮时,首先触发“compositeInfoFicheroModel()”方法,然后将其发送给指令。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)