|
1 | | -import { APP_ID, NgModule, PLATFORM_ID } from '@angular/core'; |
| 1 | +import { APP_ID, NgModule } from '@angular/core'; |
2 | 2 | import { BrowserModule } from '@angular/platform-browser'; |
3 | | -import { isPlatformBrowser } from '@angular/common'; |
4 | 3 | import { RouteReuseStrategy } from '@angular/router'; |
5 | 4 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; |
6 | 5 | import { AppComponent } from './app.component'; |
7 | 6 | import { AppRoutingModule } from './app-routing.module'; |
8 | 7 |
|
9 | | -export function ionicConfigFactory(platformId: Object): any { |
10 | | - // Custom keyboard height for lazy loaded app |
11 | | - if (isPlatformBrowser(platformId)) { |
12 | | - const isLazy = window.location.href.includes('lazy'); |
13 | | - return isLazy ? { keyboardHeight: 12345 } : {}; |
14 | | - } |
15 | | - // Default configuration for non-browser environments |
16 | | - return {}; |
| 8 | +const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined'; |
| 9 | + |
| 10 | +export function ionicConfigFactory(): any { |
| 11 | + const isLazy = isBrowser && window.location.href.includes('lazy'); |
| 12 | + return isLazy ? { keyboardHeight: 12345 } : {}; |
17 | 13 | } |
18 | 14 |
|
19 | 15 | @NgModule({ |
20 | 16 | declarations: [AppComponent], |
21 | 17 | imports: [ |
22 | 18 | BrowserModule, |
23 | 19 | AppRoutingModule, |
24 | | - IonicModule.forRoot(ionicConfigFactory(PLATFORM_ID)), |
| 20 | + IonicModule.forRoot(ionicConfigFactory()), |
25 | 21 | ], |
26 | 22 | providers: [ |
27 | 23 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, |
|
0 commit comments