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!\"
this is because this
refers to the promise itself.
do this :
let self = this;
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) {
self.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);
}