Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Injectable({ providedIn: 'root' })
export class FeatureFlagGuard implements CanActivate {
constructor(private userQuery: UserQuery) {
}
canActivate(route: ActivatedRouteSnapshot): boolean {
return this.userQuery.hasFlags(route.data.flags);
}
}
const routes: Routes = [
...
{
path: '...',
component: ProtectedComponent,
canActivate: [FeatureFlagGuard],
data: {
flags: 'b' // or ['a', 'b']
}
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment