how to enable gzip compression in angular cli for production build

Angular-cli team has removed the support for generating compress files (.gz). Github discussion url. We can use a gulp task for it. Install following npm modules: $npm install –save-dev gulp $npm install –save-dev gulp-gzip Create gulpfile.js. The file name has to be gulpfile.js not any other names. var gulp = require(‘gulp’); var gzip = require(‘gulp-gzip’); … Read more

WARNING in ./node_modules/ng2-charts/fesm5/ng2-charts.js 230:54-72 “export ‘ɵɵdefineInjectable’ was not found in ‘@angular/core’

Update: May 2021 Recently I have used [email protected] in Angular v11 and it’s working fine. You may try with the latest version npm install ng2-charts@latest // it will automatically install latest version Older ng2-charts v2.2.4 has this bug as lots of users are reporting that so down-grading to ng2-charts v2.2.3 is fine until it is … Read more

Angular component default style css display block

My pull-request has been merged. With the upcoming release of Angular CLI v9.1.0 a new option is going to be available: –displayBlock=true|false Docs: https://next.angular.io/cli/generate#component For the impatient: It’s available right now in v9.1.0-next.0 When using the CLI: ng generate component dashboard –displayBlock=true Settting a default value in angular.json: … “projectType”: “application”, “schematics”: { “@schematics/angular:component”: { … Read more

How to pipe / map an Observable in Angular

1) remove the piping part from your getClients() method 2) do the pipe-map before subscribing to getClients() or create another method, that will do only the piping part with the observable returned from getClients() mapToAddress(): Observable<Address[]> { this.getClients.pipe( map((clients: Client[]) => clients.map(client => client.address)) ) } This is important to understand: when you call .map() … Read more

Typescript 3 Angular 7 StopPropagation and PreventDefault not working

You have two different events, one is mousedown and another is click. The e.stopPropagation() only works if both of the events are of the same kind. You can change the input like this to work as expected: <input #inputBox matInput (click)=”fireEvent($event)” max-width=”12″ /> Live example: https://stackblitz.com/edit/angular-material-basic-stack-55598740?file=app/input-overview-example.ts