Migrating angular-permission to modern Angular
angular-permission defined permissions and roles, protected ui-router states through data.permissions and hid elements with directives. It is tied to AngularJS and its routers.
What replaces it
| Option | When to choose it |
|---|---|
| Route guards + your own directive | Functional guards (canActivate, canMatch) for routes and a small structural directive to show or hide elements. |
| ngx-permissions | Similar concepts to angular-permission: permissions, roles, a guard and directives. |
| CASL (@casl/angular) | When rules depend on the action and the record, not only on a role. |
How to migrate it
- Export the list of permissions and roles, and where each one is checked: states, templates and controllers.
- Create a PermissionService that loads the user's permissions once and is shared by both frameworks.
- Replace state permissions with route guards and the template directives with your own directive as each screen moves.
Watch out. Load permissions before the first navigation, or a page refresh sends logged-in users to the access-denied page. And hiding a button is not security: the API must enforce the same rules.
Other libraries
- angular-xeditable
- angular-bootstrap-datetimepicker / ui-date
- angular-pdf / pdf.js directives
- ngClipboard / angular-clipboard
Planning a migration or a micro-frontend platform?
In a 20-minute call you describe your situation and I tell you how I'd approach it. If it isn't worth doing yet, I'll say so.
Message me on LinkedIn