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

Error : Module ‘”@angular/material”‘ has no exported member “…”

You have probably updated your angular and/or angular material versions; with the angular material 9 upgrade they changed the imports from @angular/material notation to @angular/material/button like notation. Instead of importing from @angular/material, you should import deeply from the specific component. E.g. @angular/material/button. ng update will do this automatically for you. You can follow the upgrade … Read more

Mocking service in a component – mock ignored

It’s because of @Component({ providers: [FundingPlanService] <=== }) The @Component.providers takes precedence over any global providers, since using the @Component.providers makes the provider scoped only to the component. In the test, Angular creates the mocked service in the module scope and the original service in the component scope. To solve this problem, Angular provides the … Read more

How to bind to model with Angular Material ?

MatButtonToggle component doesn’t implement ControlValueAccessor therefore you can’t use ngModel on it. ngDefaultControl was introduced for other purposes. MatButtonToggle is supposed to be a part of mat-button-toggle-group. But if you want to use it as a standalone component and bind model to it here is some example of how you can do it: <mat-button-toggle [checked]=”myFlagForButtonToggle” … Read more

mat-form-field must contain a MatFormFieldControl and already imported

Actually the error doesn’t mean a module import problem, but that you’re using the mat-form-field without a valid control. The problem is here : <mat-form-field> <mat-checkbox formControlName=”active”>Active</mat-checkbox> </mat-form-field> MatChebox isn’t intended to be contained in a mat-form-field but yeah its name is not very clear … Keep just in mind that mat-form-field is the component … Read more

Angular InjectionToken throws ‘No provider for InjectionToken’

After asking on the official angular repository, it turns out to be a simple solution. Instead of passing the service name as a string, you’ll have pass the tokens through the component into the view into another component. Globally define the injection token I did this alongside my service itself to make it easier to … Read more