1
- import { ComponentFactoryResolver , Injectable , Injector , NgModuleFactory , OpaqueToken , Type } from '@angular/core' ;
1
+ import { ComponentFactoryResolver , Injectable , Injector , NgModuleFactory , NgZone , OpaqueToken , Type } from '@angular/core' ;
2
2
import { Config } from '../config/config' ;
3
3
import { DeepLinkConfig } from '../navigation/nav-util' ;
4
4
import { NgModuleLoader } from './ng-module-loader' ;
5
+ import { requestIonicCallback } from './util' ;
5
6
6
7
export const LAZY_LOADED_TOKEN = new OpaqueToken ( 'LZYCMP' ) ;
7
8
@@ -76,9 +77,8 @@ export interface LoadedModule {
76
77
/**
77
78
* @private
78
79
*/
79
- export function setupPreloading ( config : Config , deepLinkConfig : DeepLinkConfig , moduleLoader : ModuleLoader ) {
80
- return function ( ) {
81
- if ( config . getBoolean ( 'preloadModules' ) ) {
80
+ export function setupPreloadingImplementation ( config : Config , deepLinkConfig : DeepLinkConfig , moduleLoader : ModuleLoader ) {
81
+ if ( config . getBoolean ( 'preloadModules' ) ) {
82
82
const linksToLoad = deepLinkConfig . links . filter ( link => ! ! link . loadChildren && link . priority !== 'off' ) ;
83
83
84
84
// Load the high priority modules first
@@ -100,5 +100,17 @@ export function setupPreloading(config: Config, deepLinkConfig: DeepLinkConfig,
100
100
console . error ( err . message ) ;
101
101
} ) ;
102
102
}
103
+ }
104
+
105
+ /**
106
+ * @private
107
+ */
108
+ export function setupPreloading ( config : Config , deepLinkConfig : DeepLinkConfig , moduleLoader : ModuleLoader , ngZone : NgZone ) {
109
+ return function ( ) {
110
+ requestIonicCallback ( ( ) => {
111
+ ngZone . runOutsideAngular ( ( ) => {
112
+ setupPreloadingImplementation ( config , deepLinkConfig , moduleLoader ) ;
113
+ } ) ;
114
+ } ) ;
103
115
} ;
104
116
}
0 commit comments