I am unable to call a function inside promise of ng2-sweetalert2 plugin
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!'
}).then(function(x) {
this.removeNote(key);
swal(
'Deleted!',
'Your file has been deleted.',
'success'
);
}, function(e){
console.log('Cancelled');
});
removeNote(key){
this.todo.remove(key);
this.afService.closeNote(key);
}
this.removeNote()
cause error.
EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'removeNote' of undefined
How do I overcome this? I used NgZone but i get the same error