Canopy Feature Toggle — Best Practices
SkillDev toolsBest practices for the Canopy Feature Toggle module. Trigger when using LgFeatureToggleModule, the lgFeatureToggle directive, or FeatureToggleGuard in an Angular project using Canopy.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Canopy Feature Toggle — Best Practices skill
What this skill tells your AI
The instructions your AI receives, as published by legal-and-general/canopy in skills/best-practice/feature-toggle/SKILL.md and read by ahel’s review.
This skill provides usage guidance for the Canopy LgFeatureToggleModule from @legal-and-general/canopy.
Apply this skill when enabling or disabling features using observable configuration flags.
Setup
Register the module with forRoot once in your root module, providing an observable of feature flag config:
import { LgFeatureToggleModule } from '@legal-and-general/canopy';
imports: [
LgFeatureToggleModule.forRoot({
deps: [Store],
useFactory: (store: Store<CoreState>) => store.select(getFeatureToggles)
})
]
The factory must return an Observable of a config object:
{
"exampleFeature": true,
"anotherFeature": false
}
Default hide behaviour
By default, features are shown if the flag is undefined. To hide features that are not explicitly configured:
imports: [
LgFeatureToggleModule.forRoot(
{
deps: [Store],
useFactory: (store: Store<CoreState>) => store.select(getFeatureToggles)
},
{
defaultHide: true
}
)
]
Using in Feature Modules
Import LgFeatureToggleModule (without forRoot) in each feature module:
imports: [ LgFeatureToggleModule ]
Template Usage
Use the *lgFeatureToggle structural directive to conditionally render content:
<div *lgFeatureToggle="'exampleFeature'">
<p>This content is only shown when exampleFeature is true.</p>
</div>
Route Guard
Protect routes with FeatureToggleGuard:
import { FeatureToggleGuard } from '@legal-and-general/canopy';
const routes: Routes = [
{
path: 'my-feature',
component: MyFeatureComponent,
canActivate: [FeatureToggleGuard],
data: { featureToggle: 'myFeature' },
},
];
For lazy-loaded routes with child guards:
{
path: 'parent',
loadChildren: () => import('./parent/parent.module').then(m => m.ParentModule),
canActivate: [FeatureToggleGuard],
canActivateChild: [FeatureToggleGuard],
canLoad: [FeatureToggleGuard],
data: { featureToggle: 'parentToggle' },
}
Child routes can define their own featureToggle in data. The path is only accessible when all toggle flags in the route chain are true.
Signals
- GitHub stars
- 23
- Forks
- 46
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
canopy-feature-toggle- Source
- github.com/legal-and-general/canopy