Comments (8)
@amrinder23 If you use !, the only thing different is the statement app.run ()
app.run(['$rootScope', '$state', function ($rootScope, $state) {
// If the route change failed due to our "Unauthorized" error, redirect them
$rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, rejection) {
if (rejection === 'Unauthorized') {
$state.go('home');
}
});
}]);
from angular-acl.
@amrinder23 I m not as familiar with UI Router. I can figure it out and post here eventually (I'm getting ready to leave for work). In the meantime, I'd suggest searching "angular ui router protect routes" or something similar to see the mechanism for bailing out of a route based on some sort of logic. Then I'd implement this angular-acl
package into that flow.
If you find a good solution, please share 😄
from angular-acl.
@yhon92 thanks for the comment 👍
from angular-acl.
Thanks @yhon92 .. I will try this. 👍
from angular-acl.
Thanks @mikemclin for an awesome service.
Thanks @yhon92 it worked for me. $state didnt work in app.run method. I had to get its instance using $injector.get("$state"). Then it worked for me.
from angular-acl.
@mikemclin .. Just another question.
After implementing angular-acl in my application, when i refresh the browser it considers it as $stateChangeError and it goes into that code block (rejection==='Unauthorized') and sets the current state to the one set there.
Can't we remain on the same state ?
from angular-acl.
-
what version you're using ui-router?
-
I use $stateChangeStart to capture the event to load the browser, and if the key there AclService in the localStorage use the function AclService.resume(); to continue operation.
from angular-acl.
@yhon92 I am using v0.2.15 of ui-router
from angular-acl.
Related Issues (20)
- Can't get it to work
- Can't get it to work HOT 1
- Example with ng-if vs ng-show HOT 4
- dealing with 'is owner' HOT 1
- user role permissions level HOT 3
- AclService showing old value for "can" HOT 2
- Protect a route HOT 1
- Any plans for angular 2 module HOT 2
- Master branch is not updated with 0.1.8 release code HOT 1
- Cannot read property 'split' of undefined at aclShowWatchAction HOT 7
- Update IndexOf prototype check HOT 1
- Feature request HOT 1
- I always need to reload the page to get correct permission HOT 2
- Error when web storage is disabled
- Use Reverse loop to Improve read Performance;
- syntax error on documentation from Protect a route
- $q is not defined HOT 4
- How to reload the ACL data before routeProvider resolves? HOT 2
- Is there any way make tardy loading ? HOT 4
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-acl.