Typescript target warnings after Angular 15 update

To understand this warning, we first need to understand how the Angular build works. First, the TypeScript build needs to run. During this step, with the settings in the tsconfig.json, your TypeScript code is being compiled into JavaScript. If you set target to ES6, prior to Angular 15 the TypeScript build would produce ES6 code. … Read more

Angular Material Dialog return value

If anybody is interested I found a solution (not sure if it is the best one). Just disabling the default close operation so the popup does not close on backround click, while closing it with data param on background click. matDialogRef.disableClose = true;//disable default close operation matDialogRef.backdropClick().subscribe(result => { matDialogRef.close(dataToReturn); }); This way the calling … Read more

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

Smooth scroll angular2

there is a method in the window object called scrollTo(). If you set the behavior to ‘smooth’ the page will handle the smooth scroll. example (scroll to top of page): window.scrollTo({ left: 0, top: 0, behavior: ‘smooth’ }); And with fallback example: try { window.scrollTo({ left: 0, top: 0, behavior: ‘smooth’ }); } catch (e) … 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