Last active
June 14, 2023 08:42
-
-
Save nartc/a7f19cc6e42339dd872a6b45da81113e to your computer and use it in GitHub Desktop.
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
| @NgModule({ | |
| imports: [OAuthModule.forRoot({...})] // <-- how to use the configuration.json here | |
| }) | |
| export class AppModule { | |
| constructor(@Inject(AppConfig) private readonly appConfig: AppConfiguration) {} // I can inject | |
| } |
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
| { | |
| "apiBaseUrl": "https://localhost:5301" | |
| } |
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
| export interface AppConfiguration { | |
| apiBaseUrl: string; | |
| } | |
| export const AppConfig = new InjectionToken<AppConfiguration>('@@appConfiguration'); |
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
| (async () => { | |
| try { | |
| const config: AppConfiguration = await fetch('assets/configuration.json').then(res => res.json()); | |
| if (config.production) { | |
| console.log('Running in production mode'); | |
| enableProdMode(); | |
| } | |
| platformBrowserDynamic([ | |
| { provide: AppConfig, useValue: config } | |
| ]).bootstrapModule(AppModule) | |
| .catch(err => console.error(err)); | |
| } catch (e) { | |
| console.error('Error initializing', e); | |
| } | |
| })() |
Hi Mr. Chau,
I tested by creating a middleware module with forRoot strategy and declaring a static function that returns 3rd-party modules. Using forRoot is new to me so can you help me take a look at my idea? I applied and ran with Nx Library in libs using Transloco.forRoot( { prodMode } getting from environment.ts in apps folder. Personally, I think it's similar to your gist. By the way, I sent a message to your FB Messenger, please help me whenever you feel free.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any answer for
I tried nx-workspace and get in stuck with the case:
coreorshell(just naming) module underapps/folder. It leads to another problem when I wanna import services fromcoremodule.I was confused for more than a week & check
Angular Spotifyof @trungk18 but can't find any solution. Please help. Thanks in advance!