Skip to content

Commit cd066f2

Browse files
committed
Bootstrap the application using standalone APIs
1 parent 27e80ae commit cd066f2

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

angular/src/main.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
11
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2-
import { enableProdMode } from '@angular/core';
2+
import { enableProdMode, provideExperimentalZonelessChangeDetection, APP_INITIALIZER, LOCALE_ID, importProvidersFrom } from '@angular/core';
33
import { environment } from './environments/environment';
4-
import { RootModule } from './root.module';
4+
import { getCurrentLanguage } from './root.module';
55
import { hmrBootstrap } from './hmr';
66

77
import 'moment/min/locales.min';
88
import 'moment-timezone';
9+
import { provideClientHydration, BrowserModule, bootstrapApplication } from '@angular/platform-browser';
10+
import { HTTP_INTERCEPTORS, withInterceptorsFromDi, provideHttpClient } from '@angular/common/http';
11+
import { AbpHttpInterceptor } from 'abp-ng2-module';
12+
import { AppInitializer } from './app-initializer';
13+
import { API_BASE_URL } from '@shared/service-proxies/service-proxies';
14+
import { AppConsts } from '@shared/AppConsts';
15+
import { provideAnimations } from '@angular/platform-browser/animations';
16+
import { SharedModule } from '@shared/shared.module';
17+
import { ModalModule } from 'ngx-bootstrap/modal';
18+
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
19+
import { CollapseModule } from 'ngx-bootstrap/collapse';
20+
import { TabsModule } from 'ngx-bootstrap/tabs';
21+
import { ServiceProxyModule } from '@shared/service-proxies/service-proxy.module';
22+
import { RootRoutingModule } from './root-routing.module';
23+
import { RootComponent } from './root.component';
924

1025
if (environment.production) {
1126
enableProdMode();
1227
}
1328

1429
const bootstrap = () => {
15-
return platformBrowserDynamic().bootstrapModule(RootModule, {ngZone: 'noop'});
30+
return bootstrapApplication(RootComponent, {
31+
providers: [
32+
importProvidersFrom(BrowserModule, SharedModule.forRoot(), ModalModule.forRoot(), BsDropdownModule.forRoot(), CollapseModule.forRoot(), TabsModule.forRoot(), ServiceProxyModule, RootRoutingModule),
33+
provideExperimentalZonelessChangeDetection(),
34+
provideClientHydration(),
35+
{ provide: HTTP_INTERCEPTORS, useClass: AbpHttpInterceptor, multi: true },
36+
{
37+
provide: APP_INITIALIZER,
38+
useFactory: (appInitializer: AppInitializer) => appInitializer.init(),
39+
deps: [AppInitializer],
40+
multi: true,
41+
},
42+
{ provide: API_BASE_URL, useFactory: () => AppConsts.remoteServiceBaseUrl },
43+
{
44+
provide: LOCALE_ID,
45+
useFactory: getCurrentLanguage,
46+
},
47+
provideAnimations(),
48+
provideHttpClient(withInterceptorsFromDi()),
49+
]
50+
});
1651
};
1752

1853
/* "Hot Module Replacement" is enabled as described on

angular/src/root.module.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,4 @@ export function getCurrentLanguage(): string {
2828
return 'en';
2929
}
3030

31-
@NgModule({
32-
imports: [
33-
BrowserModule,
34-
BrowserAnimationsModule,
35-
HttpClientModule,
36-
SharedModule.forRoot(),
37-
ModalModule.forRoot(),
38-
BsDropdownModule.forRoot(),
39-
CollapseModule.forRoot(),
40-
TabsModule.forRoot(),
41-
ServiceProxyModule,
42-
RootRoutingModule,
43-
],
44-
declarations: [RootComponent],
45-
providers: [
46-
provideExperimentalZonelessChangeDetection(),
47-
provideClientHydration(),
48-
{ provide: HTTP_INTERCEPTORS, useClass: AbpHttpInterceptor, multi: true },
49-
{
50-
provide: APP_INITIALIZER,
51-
useFactory: (appInitializer: AppInitializer) => appInitializer.init(),
52-
deps: [AppInitializer],
53-
multi: true,
54-
},
55-
{ provide: API_BASE_URL, useFactory: () => AppConsts.remoteServiceBaseUrl },
56-
{
57-
provide: LOCALE_ID,
58-
useFactory: getCurrentLanguage,
59-
},
60-
],
61-
bootstrap: [RootComponent],
62-
})
63-
export class RootModule {}
31+

0 commit comments

Comments
 (0)