Angular bootstraping not working after browser refresh
I have a strange problem with angular bootstraping.
I cannot paste all the code, but shortly:
- there is no ng-app in index.html
- there jQuery ajax to check if I am signed
-
if i enter - i call (and everything is ok):
angular.element('body').ready(function(){ angular.bootstrap(angular.element('body'),['app']); console.log('is always called'); //is always called })
-
If I am not signed, I:
app = angular.injector(['app.templates']) content = app.get('$templateCache').get('login.html') $compile = app.get('$compile') $scope = app.get('$rootScope').$new(true) $('body').append content $compile($('body').contents())($scope) $scope.login = function() { // doing login ajax }
and it works great.
-
in $ scope.login function I am doing ajax which is angular bootstrapping app (code above) and that's ok
- In my angular app, I have a signout function that makes a simple jQuery ajax call to checkout server side.
- after successful checkout i do
window.location.reload(true/false doesn't matter)
and after reboot i see login form, i login, angular app starts and is ok - I am logged in, I have an angular app, I refresh my browser (F5) - and that's ok (check registration, upload)
Point:
While I logged out and I reload the page refresh page (F5), the registration form is visible, but after successful registration ajax angular fails to load?
Another page refresh does a registration check and is the bootstrap in the order signout does window.location.reload()
(which should be equivalent to F5) and the IS upload succeeds.
Another thing is after successful registration, I changed from angular bootstrap to window.location.reload (true / false doesn't matter), reload the page and have to do registration check which should cause angular to load, but this is NOT. I need to refresh the page one more time and it STARTS o_O
I have no idea what to do.
source to share
No one has answered this question yet
Check out similar questions: