Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example #2

Open
mikemclin opened this issue Oct 29, 2014 · 6 comments
Open

Create example #2

mikemclin opened this issue Oct 29, 2014 · 6 comments

Comments

@mikemclin
Copy link
Owner

No description provided.

@ariellav
Copy link

ariellav commented Sep 4, 2015

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);
}());

@mikemclin
Copy link
Owner Author

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?

@ariellav
Copy link

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,

@brunoneve
Copy link
Contributor

brunoneve commented Jul 19, 2016

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..

@sw-tt-mayankpatel
Copy link

It is working fine for ui-router also.
Thanks @mikemclin @brunoneve

@ariellav
Copy link

ariellav commented Jun 8, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants