【发布时间】:2018-01-13 18:08:18
【问题描述】:
我正在尝试在 angularJS 中的 $onInit 函数上进行这项工作。
popup() {
this.$log.log("popup clicked...");
}
constructor(
public $log: ILogService,
public $timeout: ITimeoutService,
public $q: IQService,
public $element: any) {
// i have tried this
$element.on("click custom:event", $q.when(() => this.popup()));
// and this.
$element.on("click custom:event", $timeout(() => this.popup(), 1000));
// I have also tried the scope (last resort)
$element.on("click custom:event", $scope.apply(() => this.popup());
}
在每种情况下,错误都是:
Uncaught TypeError: ((jQuery.event.special[handleObj.origType] || (intermediate value)).handle || handleObj.handler).apply 不是一个函数 在 HTMLElement.dispatch 在 HTMLElement.elemData.handle
有没有办法正确地创建一个承诺,以便在角度摘要中触发 jQuery 事件?
【问题讨论】:
标签: javascript angularjs typescript angular-promise