如果我有一个自定义组件,它有自己的函数。
export class ModalWindow {
public modalelement: HTMLElement;
show() {
$(this.modalelement).modal('show');
}
}有没有办法公开show()以供其他元素(比如我页面上的按钮)调用?
<modal-window></modal-window>
<button click.delegate="modal-window.show()">Show modal</button>发布于 2019-10-11 20:48:22
翻转见鬼,花了很长时间试图解决这个问题,最后决定在这里张贴。5分钟后,我算出了答案:
<modal-window view-model.ref="addmodal"></modal-window>
<button click.delegate="addmodal.show()">Show modal</button>如果你能想到什么,我很高兴听到有更好的选择?
https://stackoverflow.com/questions/58341381
复制相似问题