Reputation: 4208
I need to figure out if the user is authenticated or not so when the root component is bootstrapped it will forward the user to /signin
or load whatever page they requested. (I plan on doing that by injecting a service with a boolean if it needs to sign on before making any requests).
Angular's docs mention a "Platform Injector" or a "Root Injector". Can I access this to get a Http object? or is it created when bootstrap is called and I need to create my own injector from scratch to get Http?
Upvotes: 4
Views: 284
Reputation: 39248
Before bootstrap the http module is not registered as a valid provider, so you can't use DI to instantiate it.
It's possible that you can find a way to instantiate it manually by importing Http and do
var http = new Http(..)
but you would have to satisfy the input arguments and I am not sure if it's recommended to try to work with modules before the application is in a stable bootstrapped state.
To keep this simple my recommendation would be to do the pre angular check using some other simple http implementation like jquery etc
Upvotes: 1