Transitioning from AngularJS to Angular has posed a challenge for me, especially when it comes to moving from promises to observables. Below is an example of my code in AngularJS:
var deferred = $q.defer(),
frame = document.createElement('newFrame');
/// some code here...
frame.onload = function () {
/// code..
deferred.resolve();
}
frame.onerror = function () {
/// code..
deferred.reject();
}
document.body.appendChild(frame);
return deferred.promise;
I have been struggling to rewrite this code using observables in Angular. After browsing through various questions on StackOverflow, I came across this question. However, since I am not using HTTP API in this scenario, the conversion process seems more complex.
Is there any alternative solution available?