Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniele Zurico daniele-zurico

View GitHub Profile
View lazy.module.ts
@NgModule({
imports: [
CommonModule
],
declarations: [LazyComponent],
entryComponents: [LazyComponent]
})
export class LazyModule {
static entry = LazyComponent;
}
View app.component.ts
export class AppComponent implements AfterViewInit {
@ViewChild('testOutlet', {read: ViewContainerRef}) testOutlet: ViewContainerRef;
constructor(
private loader: NgModuleFactoryLoader,
private injector: Injector) {
}
ngAfterViewInit(): void {
const path = 'src/app/lazy/lazy.module#LazyModule';
View app.component.html
<div style="text-align:center">
<div #testOutlet></div>
</div>
View angular.json
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
...
"lazyModules": [
"src/app/lazy/lazy.module"
]
}
...
@daniele-zurico
daniele-zurico / ngx-data-table.module.ts
Created May 22, 2018
/projects/ngx-data-table/src/lib/ngx-data-table/
View ngx-data-table.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NgxDataTableComponent } from './ngx-data-table.component';
import { MatTableModule, MatPaginatorModule, MatSortModule } from '@angular/material';
@NgModule({
imports: [
CommonModule,
MatTableModule,
MatPaginatorModule,
View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgxDataTableModule } from 'projects/ngx-data-table/src/lib/ngx-data-table/ngx-data-table.module';
@NgModule({
declarations: [
AppComponent
View ngx-data-table.component.html
<div class="mat-elevation-z8">
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
<ng-container [matColumnDef]="cols" *ngFor="let cols of displayedColumns">
<mat-header-cell *matHeaderCellDef mat-sort-header> {{cols}} </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element[cols]}} </mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
View app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
data: any[] = [
View app.component.ts
import {Component} from '@angular/core';
import * as faker from 'faker';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'app';