I have an abstract class
called ParentService
and its child class
ChildService
as follows:
ParentService
import { Injectable } from '@angular/core';
import { MyModel} from './mymodel-model.service';
@Injectable({
providedIn: 'root'
})
export abstract class ParentService {
constructor() { }
word:MyModel = {
"AA":"AA",
"BB":"BB",
}
}
ChildService
import { Injectable } from '@angular/core';
import { MyModel} from './mymodel-model.service';
import { ParentService } from './parent.service';
@Injectable({
providedIn: 'root'
})
export class ChildService extends ParentService {
word2:MyModel = {
"AA":"AA2",
"BB":"BB2",
};
}
In the constructor
of the app-component
I have declared the child instance as follows:
constructor(private child_instance:ChildService){}
When printing child_instance
in the browser console I get:
ParentService {word: {…}}
Without the extends ParentService
I got:
ChildService {word2: {…}}
But I need to have both variables in the same class:
ChildService {word: {…},word2: {…}}
//or
ParentService {word: {…},word2: {…}}
How can I acomplish this?