In my search for a solution, I came across this answer but it did not quite fit my needs:
- Pass onload event through redirect
The issue I'm facing is that I want the AngularJS section of my application to reload something when the user is redirected back to the page. The login flow is as follows:
a.php -> [FB Magic] -> callback.php -> a.php
The problem lies in the fact that <body onload="foo()">
only triggers once. This holds true for DOMContentLoaded
and window.onload
as well.
For a.php, it appears as though the user never left the page.
How can I make AngularJS execute a function (defined within a controller) when the user is redirected back? (I am using PHP to handle the redirection)
EDIT: Here is what my controller looks like:
pwm.controller('EventListController', ['$scope', 'pwmApi',
function EventListController($scope, pwmApi) {
$scope.fetched = false;
$scope.events = [];
let update = function () {
<!-- Does stuff, is a bit long ->
};
update();
}]);
So, the update(); method is called upon construction of the controller. However, when I am redirected back, the update function is NOT executed - Refreshing the page resolves the issue temporarily.
I hope this clarification sheds some light on the situation. Reloading the page after being redirected back helps, but still nothing happens...