javascript - 如何将 JavaScript 库中触发的 onclick 事件绑定到 Angular 函数?
问题描述
如何将 Angular 组件内的外部可视库 (DHTMLX Gantt) 触发的“onclick”事件与同一个 Angular 组件的功能绑定?
环境:
- Angular 6 应用程序
- 外部可视化 JavaScript 库 (DHTMLX Gantt)
组件.html
<div #gantt_here style='width: 100%; height: 100%;'></div>
组件.ts
export class ProjectManagementGanttComponent implements OnInit {
@ViewChild('gantt_here') ganttContainer: ElementRef;
constructor() {
}
ngOnInit() {
// Config Gantt Library
gantt.config.columns = [
{name: 'tree', width: 30,
template: '<input type=button onclick=expand_task(' + task.id + ') value=+>'
},
{name: 'text', label: 'Task name', width: '*'}
];
// Init Gantt Library
gantt.init(this.ganttContainer.nativeElement);
}
解决方案
推荐阅读
- graphql - 石墨烯 Django 禁用建议“你是说……”
- swift - 表视图渲染?
- arrays - 将字符串数组转换为 ruby 对象的问题
- ansible - 在 Gitlab CI 中使用 Ansible 通过 JumpServer 进行连接
- batch-file - 从文本文件中提取特定行和模式之间的行可能会在文件中多次出现
- ios - 如何在iOS swift中以编程方式打开/关闭DND“请勿打扰”模式
- objective-c - 如何在objective c的其他模块中访问swift类
- angular - 尝试使用预设值制作模板驱动的表单
- node.js - 导入/导出模块 - Node JS/Discord JS
- javascript - 从 React 的其他页面打开对话框