When creating a ngxs RouteHandler according to the documentation found here:
https://www.ngxs.io/advanced/action-handlers
I get a NullInjectorError when I add:
providers: [
{
provide: APP_INITIALIZER,
useFactory: noop,
deps: [RouteHandler],
multi: true
}
]
Has anyone successfully dispatched routes from an ngxs action using this documented RouteHandler?
This one stumped me for a little bit. What I found, at least in my case, is that the docs failed to mention you need to set { providedIn: 'root' } in the "service" - so to speak.
@Injectable({ providedIn: 'root' });
Everything else was pretty much the same as explained in the docs. I also (quickly) made a stackblitz which should give you a general idea as to how things should be set up. https://stackblitz.com/github/baxelson12/ngxs-route-handlers