ngPermission

route based permission module for angular js

Homepage

Module License: LGPL-2.1

Added by: Tushar Borole

GitHub

Repository

tushariscoolster/ngpermission

Stats

Stars: 4

Watchers: 4

Forks: 1

Module Description

ngPermission

Add authorization to angular route, so restriction route to specific tole becomes so easy.

Install via bower:

bower install ngPermission

Install via npm:

npm install ngpermission

Add dependency to you module:

angular.module("your app name",["ngPermission"])

Add role permission to route:

.when('/view1', {
        templateUrl: 'view1/view1.html',
        controller: 'View1Ctrl',
        authorizedRole: ['admin']
    })

Resolve if role is present:

.run(['$rootScope', '$http', '$route', function ($rootScope, $http, $route) {
    $rootScope.$on('ngPermission', function (event,roles, defer,routeObject) {
    // do what you want to do
    //role ["admin"]
    //routeObject {templateUrl: 'view1/view1.html',controller: 'View1Ctrl',authorizedRole: ['admin']}
        $http.get('/someUrl').success(function(data){
         var indexRole = roles.indexOf(data.role);
         if(indexRole!=-1){
         defer.resolve();
         }
        });
    });
}])

Module stats last updated: 2015-06-04 11:32:00

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!