[英]Using factories from AngularJS in typescript?
我在 application.ts 文件中定义了一个这样的工厂,并向其中添加了一个模块“CrossFrameUtils”。 我想在 controller 文件中使用这个工厂(代码如下)我无法正确加载 InterruptCrossFrame:
factory('InterruptCrossFrame', ['CrossFrame', (CrossFrame) => {
return {
searchForLaborMove: () => {
return CrossFrame.call({
frame: $window,
message: {
method: 'heliosInterruptListener',
data: {
action: 'search',
parameters: true,
},
},
}).catch(errorResponse => {
$log.error('Unable to search for interrupt notifications. Error: ', errorResponse)
})
},
}
}])
When I try to load this in a controller like this :
class Controller implements ng.IComponentController {
static readonly $inject = [
'InterruptCrossFrame',
]
constructor(
private readonly InterruptCrossFrame: any, // here
) {
}
$onInit(): void {
this.activate()
}
activate(): void {
console.log('Checking for Helios notifications on this page')
this.InterruptCrossFrame.searchForLaborMove(); // and here
}
}
it throws ```this.InterruptCrossFrame.searchForLaborMove is not a function``` What Am I doing wrong?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.