【发布时间】:2019-09-19 23:06:12
【问题描述】:
我想打电话给openSnackBar,但我遇到了异常。任何人都可以请帮助我如何处理来自嵌套函数的外部方法调用?
export class DetailsComponent implements OnInit, OnDestroy
{
updateTodoPromise.then(function (fulfilled) {
// yay, you got a new phone
this.openSnackBar('Task saved successfully!', 'CLOSE');
})
.catch(function (error) {
// ops, mom don't buy it
console.log(error.message);
this.openSnackBar('Task saved successfully!','CLOSE');
});
}
public openSnackBar(full: string, full2: string) {
this.snackBar.open(full, full2, {
duration: 5000,
});
}
【问题讨论】:
标签: javascript typescript ecmascript-6 ecmascript-5