https://github.com/tushar-borole/ngpermission
:sunflower: route based role permission module for angular js, works with angular router as well as ui router
https://github.com/tushar-borole/ngpermission
Last synced: about 2 months ago
JSON representation
:sunflower: route based role permission module for angular js, works with angular router as well as ui router
- Host: GitHub
- URL: https://github.com/tushar-borole/ngpermission
- Owner: tushar-borole
- Created: 2015-05-31T09:01:17.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-07-18T21:35:17.000Z (almost 8 years ago)
- Last Synced: 2025-04-02T15:11:27.928Z (2 months ago)
- Language: JavaScript
- Homepage: http://tushariscoolster.github.io/ngPermission
- Size: 599 KB
- Stars: 11
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```sh
bower install ngPermission
```Install via npm:
```sh
npm install ngpermission
```Add dependency to you module:
```javascript
angular.module("your app name",["ngPermission"])
```Add role permission to **ngRoute**:
```javascript
.when('/view1', {
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl',
authorizedRole: ['admin']
})
```Add role permission to **ui.router**:
```javascript
.state('view1', {
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl',
authorizedRole: ['admin']
});
```Resolve if role is present:
```javascript
.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
});
}]);
```