Comments (8)
Hi there, and thanks for checking out my code :)
The $routeChangeStart
event actually also triggers on the initial page load after Angular has boostrapped the app.
Definitely check out the live deployment: http://angular-client-side-auth.herokuapp.com/
There you will notice that it will redirect you to the login page right away even though the URL I just posted in this comment points to the root. Same thing happens if you try to go straight to /admin or some other restricted route.
from angular-client-side-auth.
Well in my app this is not the case. The route change is not triggered on page load and I use exactly your code. I had to do
$location.path('/login');
$rootScope.$on("$routeChangeStart", function (event, next, current) {
$location.path('/login');
});
This works. very strange. I have asked a question regarding this problem on SO http://stackoverflow.com/questions/16605199/redirect-when-app-is-initialized-in-angularjs
from angular-client-side-auth.
Hmmm, that's quite strange... Do you get the same behaviour when visiting http://angular-client-side-auth.herokuapp.com/? Do you get any error messages in the console of Chrome Developer Tools/Firebug when loading the page?
from angular-client-side-auth.
Perhaps you could make a jsFiddle where you reproduce the problem? That would make it a lot easier to debug for me :)
from angular-client-side-auth.
No there are no error in console. I've setup a fiddle http://jsfiddle.net/Edsvt/ But it is not working, not sure why. However it show describe my code quite well.
from angular-client-side-auth.
Hello,
is the problem not somewhere in app the configuration.. try with commenting the code below if you have:
app.use(app.router);
from angular-client-side-auth.
I copied the jsFiddle code to my local machine, and played around with it a little bit. I was a little puzzled at first too, since there were no reported errors, the run function seemed to work, and though the $routeChangeStart
handler was successfully registered on the $rootScope
it was never fired. However, the reason is quite simple: You do not have an ngView
attribute in your HTML, so the $route
service didn't know where to render your templates and thus handle route changes. Read more about ngView
here: http://docs.angularjs.org/api/ng.directive:ngView
from angular-client-side-auth.
http://docs.angularjs.org/api/ng.directive:ngView is Offline and i the JsFiddle is also not working on my maschine and angular build (v1.5.8)
from angular-client-side-auth.
Related Issues (20)
- Replace $cookieStore to $cookies HOT 1
- I am new to npm and angular, I tried on windows 8.1, i was able to complete npm install, but npm start gave error HOT 1
- Server depends on a file located in the client directory HOT 1
- book mark HOT 2
- npm install throwing me to include npm-debug.log
- react js issue
- npm run build error HOT 3
- Can't start the "npm run dev" on my ubuntu 17.10 Laravel 5.5
- I am new with Node and it gives me error whenever i run npm start command.Can anyone please help me....
- i have error when i write npm start
- I'm new with Node
- Unresolved variable or type routingConfig HOT 2
- Google Logout HOT 2
- How about using JWT instead of cookies HOT 5
- "data.access" in toState is always false HOT 2
- Integration with Django HOT 3
- Social sites login
- Question about passing the user to HTTP GET * HOT 1
- Use ng-if instead CSS HOT 5
- any sample with asp.net mvc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-client-side-auth.