How to update / upgrade from Angular 4 to Angular 5+

This specific problem was fixed with Node version update. I had to update Node version, sudo apt-get install nodejs npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest ng new ProjectName node –version ==> 8.9.0 ng –version ==> 1.5.0 “dependencies”: { “@angular/animations”: “^5.0.0”, “@angular/common”: “^5.0.0”, “@angular/compiler”: “^5.0.0”, “@angular/core”: “^5.0.0”, “@angular/forms”: “^5.0.0”, “@angular/http”: “^5.0.0”, … Read more

RangeError: Maximum call stack size exceeded when using valueChanges.subscribe

If you want to subscribe to any form changes and still run patchValue inside it, then you could add the {emitEvent: false} option to patchValue, thus the patching will not trigger another change detection code: this.formGroup .valueChanges .subscribe( _ => { this.formGroup.get( ‘controlName’ ).patchValue( _val, {emitEvent: false} ); } ); PS. This is also less … Read more

How to set color of toggle buttons

matButtonToggle does not support the color property like matButton. You can use the css classes .mat-button-toggle and .mat-button-toggle-checked to style the different states. With material theming you can extract whichever individual palettes you need from the theme and apply the backgrounds default-contrast color to the text color to achieve optimal contrast with light or dark … Read more

Catch error in combined pipe of pipeable rxjs operators

After refactoring you moved map out of switchMap projection, so any error will close the outer stream. To keep both streams equivalent, you need to use pipe in the projection itself like that: import { EMPTY } from ‘rxjs’; // … @Effect() loadData$ = this.actions$ .ofType(LOAD_DATA) .pipe( map((action: LoadData) => action.payload), withLatestFrom(this.store.select(getCultureCode)), switchMap(([payload, cultureCode]) => … Read more

How to create a url string with query parameters from an object in Angular 5+?

You can use just Router and UrlSerializer: constructor(private router: Router, private serializer: UrlSerializer) { const tree = router.createUrlTree([], { queryParams: { foo: ‘a’, bar: 42 } }); console.log(serializer.serialize(tree)); // “/?foo=a&bar=42” } See demo: https://stackblitz.com/edit/angular-basic-template-3hx9at?file=src/app/hello.component.ts