MAT_DATE_FORMATS definition/meaning of fields

Well, I figured out the following: parse: { dateInput: ‘DD.MM.YYYY’, }, display: { dateInput: ‘DD.MM.YYYY’, monthYearLabel: ‘MMM YYYY’, dateA11yLabel: ‘LL’, monthYearA11yLabel: ‘MMMM-YYYY’, }, with parse.dateInput: you can let the user enter any type of date with any format, and the date adapter will reformat it to the format you specify in this attribute with display.dateInput … Read more

NgRx – Order of execution of Reducers and Effects

Edit: NgRx effects fire after all reducers for that action have executed. That order is guaranteed. The reduced state is the payload of your effects. Found the following comment in lifecycle_hooks.d.ts in the NgRx effects-build project: By default, effects are merged and subscribed to the store. Implement the OnRunEffects interface to control the lifecycle of … Read more

How to subscribe to event emitter once?

A call to subscribe returns an instance of Disposable, which has a method dispose. Or if you are using RxJS 5, dispose has been renamed to unsubscribe (thanks @EricMartinez). And from the RxJS docs: …when we’re no longer interested in receiving the data as it comes streaming in, we call dispose on our subscription. Store … Read more

Angular 14 strictly typed reactive forms – How to type FormGroup model using existing interface

I also ran into this because I always assign my FormGroup later and I was not happy about having to add a ton of boilerplate types on every FormGroup declaration. It felt like I was repeating myself, so what I ended up doing was creating a utility type which has been working well. export type … Read more

Manually trigger pipe update

First way: paremeter One way to make a Pure Pipe becoming impure is add a parameter to your Pipe. when you want to refresh, just change the parameter. Second way: without parameter Pure Pipe will be fired when its input has a new instance. So with TypeScript 2.1+, the below code will copy the original … Read more

Angular 4 Pipe Filter

Here is a working plunkr with a filter and sortBy pipe. https://plnkr.co/edit/vRvnNUULmBpkbLUYk4uw?p=preview As developer033 mentioned in a comment, you are passing in a single value to the filter pipe, when the filter pipe is expecting an array of values. I would tell the pipe to expect a single value instead of an array export class … Read more

Angular2 detect change in service

Edit: Following the Mark’s comment, a Subject / Observable should be preferred: EventEmitter should only be used for emitting custom Events in components, and that we should use Rx for other observable/event scenarios. Original Answer: You should use an EventEmitter in the service: export class LangService { langUpdated:EventEmitter = new EventEmitter(); setLang(lang) { this.lang = … Read more

Angular http.post without .subscribe callback

I do not think you can. http.post (and get, put, delete, etc) returns a cold Observable, i.e. an Observable for which: its underlying producer is created and activated during subscription Source. This means the function represented by the Observable is activated only with the subscribe() method. Convenience methods subscribe too, see implementation details for Observable#toPromise() … Read more

Angular2 router – Navigate to the current page with different parameters

The page will not refresh, cause that’s how the Router works.. without refreshing the page! You have to subscribe to the route parameters to detect changes in them and then do whatever you want to with that information.. So inject ActivatedRoute into your component and subscribe to the parameters like this: constructor(private route: ActivatedRoute) {} … Read more

Angular 2 observable subscribing twice executes call twice

You may use the share operator on your result from HttpClient.get, like this: var observable = this.httpClient.get(‘api/version/secured’, { headers: httpHeaders }) .pipe(share()); You’ll need to add the following import on top of your script: import { share } from ‘rxjs/operators’; The share operator makes an observable hot, i.e. shared between subscribers. But there’s a lot … Read more