back in RC4 when HTTP_PROVIDERS existed I could create my custom http instance using
export function createHTTP(url:string, headers?:Headers){
let injector = ReflectiveInjector.resolveAndCreate([
myHttp,
{provide:'defaultUrl', useValue:url},
{provide:'defaultHeaders', useValue:headers || new Headers()},
...HTTP_Providers
])
return injector.get(myHttp)
}
myHttp was a wrapper for Http
@Injectable()
export class myHttp{
constructor(@Inject('defaultUrl) private url:string, @Inject('defaultHeaders) private headers:Headers, private http:Http){}
get()
put()...
}
Now with HTTP_PROVIDERS deprecated and removed, how do I provide it?
Thanks!
or copy the definition of
HTTP_PROVIDERS
from the Angular2 source to your source and use it there like before.You can also create an injector yourself using these providers like
See also Inject Http manually in angular 2