Code Monkey home page Code Monkey logo

Comments (6)

ariellav avatar ariellav commented on June 17, 2024

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.

mikemclin avatar mikemclin commented on June 17, 2024

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.

ariellav avatar ariellav commented on June 17, 2024

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.

brunoneve avatar brunoneve commented on June 17, 2024

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.

sw-tt-mayankpatel avatar sw-tt-mayankpatel commented on June 17, 2024

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

from angular-acl.

ariellav avatar ariellav commented on June 17, 2024

from angular-acl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.