Skip to content

Instantly share code, notes, and snippets.

View thisiszoaib's full-sized avatar

Zoaib thisiszoaib

View GitHub Profile
@thisiszoaib
thisiszoaib / app.component.ts
Last active October 10, 2020 06:59
Code splitting 3
dynamicComponent: Type<ReportCardComponent>;
constructor() { }
async loadComponent(): Promise<any> {
const imported = await import('./report-card/report-card.component');
this.dynamicComponent = imported.ReportCardComponent;
}
@thisiszoaib
thisiszoaib / app.component.ts
Created October 10, 2020 06:58
Code splitting 2
dynamicComponent: Type<ReportCardComponent>;
constructor() { }
async loadComponent(): Promise<any> {
const imported = await import('./report-card/report-card.component');
this.dynamicComponent = imported.ReportCardComponent;
}
@thisiszoaib
thisiszoaib / app-routing.component.ts
Created October 10, 2020 06:55
Code splitting 1
const routes = [
{
path: 'academics',
loadChildren: () => import('./academics/academics.module').then((m) => m.AcademicsModule)
}
]
export class AppComponent {
constructor(private pdfService: PdfService) {
}
generatePdf() {
this.pdfService.generatePdf();
}
}
export class PdfService {
pdfMake: any;
constructor() { }
async loadPdfMaker() {
if (!this.pdfMake) {
const pdfMakeModule = await import('pdfmake/build/pdfmake');
const pdfFontsModule = await import('pdfmake/build/vfs_fonts');
this.pdfMake = pdfMakeModule.default;
export class PdfService {
pdfMake: any;
async loadPdfMaker() {
if (!this.pdfMake) {
const pdfMakeModule = await import('pdfmake/build/pdfmake');
const pdfFontsModule = await import('pdfmake/build/vfs_fonts');
this.pdfMake = pdfMakeModule.default;
this.pdfMake.vfs = pdfFontsModule.default.pdfMake.vfs;
}
<mat-toolbar color="primary">
PDF Generator with PDFMake
</mat-toolbar>
<button mat-raised-button color="primary">
Generate PDF
</button>
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatButtonModule } from '@angular/material/button';
@NgModule({
declarations: [
AppComponent
<mat-list>
.......
<div class="spinner-item">
<mat-progress-spinner [mode]="'indeterminate'" [diameter]="50">
</mat-progress-spinner>
</div>
</mat-list>
this.loading = true;
timer(1000).subscribe(() => {
this.loading = false;
this.listItems = [...this.listItems, ...newItems];
});