tushar-borole / ngPermission

:sunflower: route based role permission module for angular js, works with angular router as well as ui router

Home Page:http://tushariscoolster.github.io/ngPermission

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ngPermission

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

Note:- Works with ui.route as well as ngRoute :)

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 ngRoute:

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

Add role permission to ui.router:

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

Resolve if role is present:

.run(['$rootScope', '$timeout','$state', function ($rootScope, $timeout,$state) {

    $rootScope.$on('ngPermission', function (event, defer,toState, toParams, fromState, fromParams) {
     console.log(toState)
        $timeout(function () {
            defer.resolve();
        }, 5000)

        // do what you want to do
    });
}]);

About

:sunflower: route based role permission module for angular js, works with angular router as well as ui router

http://tushariscoolster.github.io/ngPermission


Languages

Language:JavaScript 56.0%Language:HTML 41.9%Language:CSS 2.2%