所以我在我的应用中使用了uikit confirmation modal。我的问题是,当我要点击<button>
进行确认时。 this
里面的函数是undefined
。这里是我的代码...'this'在函数()中是未定义的。 angular 2
declare var UIkit:any;
deleteData(dataArr): void {
UIkit.modal.confirm('Are you sure you want to delete this?', function() {
console.log(dataArr);
console.log(this);
//use service here...
UIkit.modal.alert('Confirmed!');
});
}
内部的功能,我希望为HTTP请求使用服务,但我有在this
一个问题。我正在使用Angular 2.x.
'()=> {'... ... –
[setTimeout和JavaScript中的this this]可能重复(https://stackoverflow.com/questions/591269/settimeout-and-this- in-javascript)| https://stackoverflow.com/questions/34930771/why-is-this-undefined-inside-class-method-when-using-promises –