Answer the question
In order to leave comments, you need to log in
How to use an alias on an Angular class?
I have a class that receives a different value of the type parameter (1,2,3) as input to the constructor, inside the class a request is made to the server with this type type. The data is returned.
I need to have 3 instances of this class in the component, for this I requested them:
providers: [
{ provide: Search, deps: [CLOUD_SERVICE, SEARCH_CONFIG_ONE] },
{ provide: Search, deps: [CLOUD_SERVICE, SEARCH_CONFIG_TWO] },
{ provide: Search, deps: [CLOUD_SERVICE, SEARCH_CONFIG_THIRD] }
]
constructor(public search: Search as SearchOne, public searchtwo: Search as SearchTwo, public searchThird: Search as SearchThird) {
}
Answer the question
In order to leave comments, you need to log in
I need to have 3 instances of this class in the component, for this I requested them:
constructor(@Inject(Search) public search: Search[]){}
It looks like you need an abstract class and three of its implementations, and expose them under their names.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question