I am a bit new to Angular and trying to understand code written by a senior dev. pardon me if I do not follow with the standard communication practice and words.
I have an abstract class abstractDatService with an abstract method getEntities() which have the implementation classes as impl1 and impl2
Implementation class looks like :
@Injectable()
export class impl1 extends abstractDatService{
private entities: Modal[] = [
{
id: 1,
type: "a",
name: "a1"
},
{
id: 2,
type: "a",
name: "a2"
}
];
public getEntities(): Observable<Modal[]> {
return of(this.entities);
}
}
Now, in my module, I am trying to inject the service as :
providers: [
{
provide: abstractDatService,
useClass: impl1
},
{
provide: abstractDatService,
useClass: impl2
}
]
In this case, when I try to get the entities they return me the entities from impl2 class only and not of impl1
I want the implementation to return both.
Can anyone help me figure out this?
EDIT :
To elaborate
I have the component where I am displaying the data in a way that
HEAD1
Data from impl1 // this line is a common component in which there is a ngFor on observable returned.
HEAD2
Data from impl2 // this line is a common component in which there is a ngFor on observable returned.
The common component is the one that displays Data from impl1 and Data from impl2 Both