【发布时间】:2017-10-26 04:38:20
【问题描述】:
我正在研究一个函数,有人可以就如何指定函数之外的函数提供建议吗? 在 if 语句中,我想调用 otherfunction()。
@Injectable()
export class menuService {
constructor (){}
testing(){ console.log('something')}
loadwidget(){
// not able to call this function
this.testing()
}
}
我得到的错误是“this.testing is not a function”
ERROR TypeError: this.testing is not a function
at Object.menuService.loadwidget (http://localhost:3000/main.bundle.js:755:14)
at Object.eval [as handleEvent] (ng:///AppModule/tbuttonsComponent.ngfactory.js:36:41)
at handleEvent (http://localhost:3000/vendor.dll.js:13146:138)
at callWithDebugContext (http://localhost:3000/vendor.dll.js:14354:42)
at Object.debugHandleEvent [as handleEvent] (http://localhost:3000/vendor.dll.js:13942:12)
at dispatchEvent (http://localhost:3000/vendor.dll.js:10121:21)
at http://localhost:3000/vendor.dll.js:10711:38
【问题讨论】:
标签: javascript angular types