Comments (6)
Hi there,
Awesome service you built out. I set the roles and abilities in my app.run and was able to get it working with my router. Now I am trying to use the AclService in other controllers, but the values don't carry over. How can I preserve the AclService to use across my app? This is an example of one of the controllers I am using:
(function () {
var app = angular.module("mainApp");
function routeUserController($rootScope, $scope, $http, $location, AclService) {
$scope.can = AclService.can;
console.log($scope.can('view_map'));
console.log(AclService.hasRole('psAdmin'));
}
app.controller("RouteUserController", routeUserController);
}());
from angular-acl.
Theoretically, the code you are showing should work. It seems like you might have an issue elsewhere in your app. What values does the code you posted log out into the console? What values were you expecting?
Can you also provide the run
code block, so I can inspect it?
from angular-acl.
Hey,
Thanks for your reply and this awesome angular-acl module. I was running into something issues that ngRoute was giving me and migrated to ui-router instead. Now, everything is working much more smoothly, and the AclService is preserved across the app!
Thank you,
from angular-acl.
I use so , with ngRoute
app.run(['$rootScope', 'AclService',
function($rootScope, AclService) {
AclService.resume();
$rootScope.acl = AclService;
}
]);
throughout my app, template, I can use the acl calling dependent functions.
so
<li ng-show="acl.can('client.add')">
<a ng-href="#/clients/new"><i class="fa fa-user-plus"></i> Adicionar</a>
</li>
or acl.hasRole('admin') , etc..
from angular-acl.
It is working fine for ui-router also.
Thanks @mikemclin @brunoneve
from angular-acl.
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
- Does it work with ui-router HOT 8
- 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.