I have a typescript class representing a model and I would like instances to communicate with an API via angular's Http
service.
But the constructor of the model needs arguments when creating instances. For example something super simple:
class SomeModel{
constructor(public id:number, public name:string, ){
}
I would like to inject the Http
service so it is available to my instances, but it seems like the canonical way to do this commandeers the constructor with:
constructor(http:Http)
I've been digging through the Injector
docs, but it's a little sparse and I haven't found anything that works. Is there a way to get a reference to a service like Http
from the DI system without using the constructor pattern?