[英]Is there a way to call a typescript function from javascript file?
我在打字稿文件中有一個“獲取”功能,我需要在其他javascript文件中使用此功能。 有辦法實現嗎?
我試圖在函數名稱前寫“ static”和“ public”,但是沒有用。
您可以聲明一個HostListener
組件代碼:
@HostListener('window:yourFunction', ['$event','$event.detail.type'])
yourInternalFunction(event,param) {
//do something
}
在js文件上
window.dispatchEvent(new CustomEvent('yourFunction', {detail:{type:1}}));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.