ngx-hover-preload-v2
v1.0.0
Published
An Angular preloading strategy for loading routes on link hover
Downloads
36
Maintainers
Readme
ngx-hover-preload-v2
Based on ngx-hover-preload
This package exports:
PreloadingStrategy
, which will preload a lazy-loaded route on mouse over a corresponding router link.PreloadOnDemandService
, which can be used to directly load a module that contains a given route path.
Example
Usage
- Install the package:
npm install --save ngx-hover-preload-v2
- Import the
HoverPreloadModule
into yourAppModule
AND your lazy-loaded modules to ensure the link hover directive is available:
// ...
import { HoverPreloadModule } from 'ngx-hover-preload-v2';
@NgModule({
declarations: [
// ...
],
imports: [
// ...
HoverPreloadModule
],
bootstrap: [AppComponent]
})
export class AppModule { }
- Set your
RouteModule
preload strategy toHoverPreloadStrategy
:
// ...
import { HoverPreloadStrategy } from 'ngx-hover-preload-v2';
@NgModule({
// ...
imports: [RouterModule.forRoot(routes, { preloadingStrategy: HoverPreloadStrategy })],
})
export class AppModule {} // or AppRoutingModule
License
MIT