Created
January 28, 2021 10:48
-
-
Save armanozak/88930c92c2c5b3794618909b4c10a70c to your computer and use it in GitHub Desktop.
[How to Configure Angular Modules Loaded by the Router] Making a module configurable #blog #angular
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// other imports are removed for brevity | |
import { ModuleWithProviders } from "@angular/core"; | |
@NgModule({ | |
imports: [ | |
RouterModule.forChild([ | |
{ | |
path: "", | |
component: FooComponent | |
} | |
]) | |
], | |
declarations: [FooComponent] | |
}) | |
export class FooModule { | |
static withOptions(foo = "foo"): ModuleWithProviders<FooModule> { | |
return { | |
ngModule: FooModule, | |
providers: [ | |
{ | |
provide: FOO, | |
useValue: foo | |
} | |
] | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment