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

CommonModule vs BrowserModule in angular

What you have to understand is, with Angular, you create modular application and there are two types of modules. One is root module and another is feature module. Root module imports the BrowserModule (if you are rendering in browser). This has the same stuffs as CommonModule but also stuffs that are used for rendering. Now … Read more

How to listen for value changes from class property TypeScript – Angular

You can still check component’s field members value change by KeyValueDiffers via DoCheck lifehook. import { DoCheck, KeyValueDiffers, KeyValueDiffer } from ‘@angular/core’; differ: KeyValueDiffer<string, any>; constructor(private differs: KeyValueDiffers) { this.differ = this.differs.find({}).create(); } ngDoCheck() { const change = this.differ.diff(this); if (change) { change.forEachChangedItem(item => { console.log(‘item changed’, item); }); } } see demo.

Uncaught (in promise): Error: StaticInjectorError(AppModule)[options]

Here is what worked for me (Angular 7): First import HttpClientModule in your app.module.ts if you didn’t: import { HttpClientModule } from ‘@angular/common/http’; … imports: [ HttpClientModule ], Then change your service @Injectable() export class FooService { to @Injectable({ providedIn: ‘root’ }) export class FooService { Hope it helps. Edit: providedIn Determines which injectors will … Read more

How to call JavaScript functions from Typescript in Angular 5?

1. How and where to include JavaScript Files in Angular Project? You need to include your JS file in the asset folder and refer this JS file in .angular-cli.json file. Refer the snapshot’s, Folder structure should be like this. .angular-cli.json 2. How to call the JavaScript Functions from Typescript class? your TS should be like … Read more