I've integrated a UIkit confirmation modal into my app. However, I'm encountering an issue when trying to click the <button>
for confirmation. The this
inside the function is showing up as undefined
. Here's the snippet of code in question...
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!');
});
}
While attempting to use a service for an HTTP request within that function, I am facing difficulties with the this
reference. Just to provide some context, I am working with Angular 2.x.