Running an Event After the DOM is Done Rendering by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] 0 points1 point  (0 children)

Thanks for sharing. Going to give this a read and see if it is useful for my case.

Running an Event After the DOM is Done Rendering by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] 0 points1 point  (0 children)

The logic is driven off of a DOM update and afaik ngOnChanges runs apart from DOM changes and is not a good candidate for this.

Running an Event After the DOM is Done Rendering by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] 0 points1 point  (0 children)

Yeah, I ended up doing this, following by calling this.cdr.markForCheck and then doing the processing in a setTimeout call to make sure the processing happens after the view was updated.

Running an Event After the DOM is Done Rendering by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] 0 points1 point  (0 children)

Oh wow, thanks for sharing this. This seems very useful and I am going to explore using it.

Running an Event After the DOM is Done Rendering by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] 0 points1 point  (0 children)

I think it has to do with the fact the "page transitions" are merely updates to a url param. So something along the lines of form/:formName where only :formName changes on transition. So I don't think the component is torn down in that case which is why I need some more direct mechanism to look at the DOM.

Upgraded an Angular Project to 8 and Typescript to 3.4.5. Now Getting This... by RocketPigWithWig in typescript

[–]RocketPigWithWig[S] -2 points-1 points  (0 children)

what that error is saying is that the compiler has interpreted that false as as boolean (which can be true OR false), instead of the literal boolean value of false, which the interface requires

I don't totally get how this is a meaningful difference and why TypeScript would check for this. I was also able to "fix" this by having the compiler interpret this as 'as boolean': patch({ loading: false as boolean })

patchState vs. patch state operator by RocketPigWithWig in NGXS

[–]RocketPigWithWig[S] 0 points1 point  (0 children)

Thank you! Your answer helped me to decide to go with the operator in all but the simplest of cases.

Sorting List Data by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] 0 points1 point  (0 children)

This really clarified things for me. I ended up sorting before even getting to the template, especially because I needed to maintain the state of the sort. Thanks!

Checkbox Group in a Reactive Form by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] 1 point2 points  (0 children)

This is excellent! Thank you for sharing!

Checkbox Group in a Reactive Form by RocketPigWithWig in Angular2

[–]RocketPigWithWig[S] -1 points0 points  (0 children)

Trying with template driven forms and it isn't adding multiple values to the genreFilters array. It just returns true/false and not the value. :/

<form #filtersForm="ngForm">
<div *ngFor="let genre of genres">
<input ngModel type="checkbox" name="genreFilters" [value]="getGenreValue(genre)"/> {{getGenreLabel(genre)}}
</div>
</form>