Reputation: 3429
I am downloading a text file from server.
I want to execute the next command once the file has been downloaded.
I am doing this :
window.open(location.pathname+'api/generateFile','_blank');
$scope.searchBls();
Is there a way to make sure that $scope.searchBls() is called only once window.open has finished?
Thanks
Upvotes: 1
Views: 45
Reputation: 4446
Quite simple: window.open
var win = window.open(location.pathname+'api/generateFile','_blank');
win.onload = $scope.searchBls;
You might want to handle the case where the popup has been blocked. In that case win will be undefined
Upvotes: 0
Reputation: 3324
Bind to the window.onload
event
var win = window.open(location.pathname+'api/generateFile','_blank');
win.onload = function() {
$scope.searchBls();
};
Upvotes: 1