I am trying to lazy load the third-party libraries but I couldn't find any solution if anyone have any idea please share.
Asked
Active
Viewed 638 times
1
-
do you mean something like https://stackoverflow.com/questions/44024823/how-do-i-lazy-load-an-external-module-from-node-modules ? Is it a route? – Suraj Rao Sep 28 '21 at 05:08
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Oct 06 '21 at 09:33
1 Answers
0
It’s very easy just add import followed by the relative path to 3rd party library (resided in assests
folder) & rest of the thing will be done by Angular CLI
.
thirdParty.component.ts
import { Component, OnInit } from '@angular/core';
import '../../../../assets/3rd_Party_library.js';
@Component({
selector: 'app-thirdParty',
templateUrl: './thirdParty.component.html',
styleUrls: ['./thirdParty.component.css']
})
export class ThirdPartyComponent implements OnInit {
constructor() { }
ngOnInit() { }
}
thirdParty-routing.module.ts
import { ThirdPartyComponent } from './thirdParty/thirdParty.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [{
path: '',
component: ThirdPartyComponent
}];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ThirdPartyRoutingModule { }
thirdParty.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ThirdPartyRoutingModule } from './thirdParty-routing.module';
import { ThirdPartyComponent } from './thirdParty/thirdParty.component';
@NgModule({
imports: [
CommonModule,
ThirdPartyRoutingModule
],
declarations: [ThirdPartyComponent]
})
export class ThirdPartyModule { }

Salahuddin Ahmed
- 4,854
- 4
- 14
- 35