SpyNgModuleFactoryLoader

SpyNgModuleFactoryLoader

Stable Class

What it does

Allows to simulate the loading of ng modules in tests.

How to use

const loader = TestBed.get(NgModuleFactoryLoader);

@Component({template: 'lazy-loaded'})
class LazyLoadedComponent {}
@NgModule({
  declarations: [LazyLoadedComponent],
  imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]
})

class LoadedModule {}

// sets up stubbedModules
loader.stubbedModules = {lazyModule: LoadedModule};

router.resetConfig([
  {path: 'lazy', loadChildren: 'lazyModule'},
]);

router.navigateByUrl('/lazy/loaded');

Class Overview

class SpyNgModuleFactoryLoader implements NgModuleFactoryLoader {
  constructor(compiler: Compiler)
  
  
  stubbedModules 
  load(path: string) : Promise<NgModuleFactory<any>>
}

Class Description

Annotations

@Injectable()

Constructor

constructor(compiler: Compiler)

Class Details

stubbedModules
load(path: string) : Promise<NgModuleFactory<any>>

exported from router-testing-index, defined in router/testing/src/router_testing_module.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/docs/ts/latest/api/router/testing/index/SpyNgModuleFactoryLoader-class.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部