angular-acl icon indicating copy to clipboard operation
angular-acl copied to clipboard

Create example

Open mikemclin opened this issue 10 years ago • 6 comments

mikemclin avatar Oct 29 '14 04:10 mikemclin

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

ariellav avatar Sep 04 '15 02:09 ariellav

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?

mikemclin avatar Sep 08 '15 11:09 mikemclin

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,

ariellav avatar Sep 11 '15 17:09 ariellav

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

brunoneve avatar Jul 19 '16 20:07 brunoneve

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

sw-tt-mayankpatel avatar Mar 09 '17 07:03 sw-tt-mayankpatel

Hi,

I'm actually not the creator of the issue so I don't have permissions to close it.

My apologies, I should have opened another Issue during that time and it seemed to have tangent off quite a bit.

Best,

On Wed, Jun 7, 2017 at 11:21 AM, Surendra Kumar B [email protected] wrote:

Hey @ariellav https://github.com/ariellav

Could you please close this issue if it works well for you?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mikemclin/angular-acl/issues/2#issuecomment-306881962, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0WeV9xUVMBfc7eQq2ijW7vyCoT3io-ks5sBuoWgaJpZM4C0OTl .

--

ariellav avatar Jun 08 '17 06:06 ariellav