我有一種綁定到我的角度組件的方法,名爲onCellPrepared 我在方法中使用jquery附加了span標記,在span標記的onclick事件內我想調用一種角色服務將路線導航到另一個頁面?調用routingService在javascript函數中導航時發出的問題
如何在我的javascript方法中調用角度服務。目前它顯示錯誤當我打電話
this.routerService.navigate(...)
我可以路由通過Java腳本設置頁面應該導航點擊跨度區域,它仍然應該通過角度路由配置。
onCellPrepared(e:any) { if (e.cell && e.cell.type == "D") { $('<span>') .addClass('fa fa-cog') .click(function(arg) { sessionStorage.setItem("filter", JSON.stringify([e.cell.path])); this.routerService.navigate(["reconciliation-detail"]); }) .appendTo(e.cellElement); } }
,你可以把這些代碼也將使用角時,jQuery是不建議反引號 – rjustin
的資源。您可以使用括號捕獲事件 – rjustin
不要將您與我的最後一條評論混淆,但我的建議是在html模板中捕獲click事件(click)=「callbackfunction()」,並在callbackfunction()中執行任何驗證檢查。 。否則,我提供了一個可能有所幫助的答案。 – rjustin