Skip to content

Instantly share code, notes, and snippets.

@stalniy
Created April 28, 2019 14:56
Show Gist options
  • Save stalniy/97a7b772652e34e48ac3f02eae4a8c0d to your computer and use it in GitHub Desktop.
Save stalniy/97a7b772652e34e48ac3f02eae4a8c0d to your computer and use it in GitHub Desktop.
CASL in Angular app
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AbilityModule } from '@casl/angular';
import { Ability } from '@casl/ability';
import { defineAbilitiesFor, createAbility } from '../services/ability';
import { AppRoutingModule } from './routing.module';
@NgModule({
declarations: [
...
],
imports: [
...,
BrowserModule,
AppRoutingModule,
AbilityModule.forRoot(),
],
providers: [
{ provide: Ability, useFactory: createAbility }
],
bootstrap: [App]
})
export class AppModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment