Answer the question
In order to leave comments, you need to log in
How to assign a context to a base class in Angular (with TypeScript)?
Here is my base component:
// VirtualComponent.ts
export class VirtualComponent implements OnInit, OnDestroy, AfterContentInit, AfterViewInit {
constructor(public ref: ChangeDetectorRef,
public zone: NgZone,
public route: ActivatedRoute,
public router: Router,
public applicationRef: ApplicationRef) {
}
// .. методы для вызова change detection
}
// step-list.component.ts
@Component({
// ..
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class StepComponent extends VirtualComponent {
constructor(public appState: AppState,
public dataService: DataService,
private titleService: Title,
public ref: ChangeDetectorRef,
public zone: NgZone,
public route: ActivatedRoute,
public router: Router,
public applicationRef: ApplicationRef
) {
super(appState, ref, zone, route, router, applicationRef);
}
}
export class VirtualContext {
constructor(public ref: ChangeDetectorRef,
public zone: NgZone,
public route: ActivatedRoute,
public router: Router,
public applicationRef: ApplicationRef) {
}
}
export class VirtualComponent implements OnInit, OnDestroy, AfterContentInit, AfterViewInit {
public ref: ChangeDetectorRef;
public zone: NgZone;
// ..
constructor(public virtualContext: VirtualContext) {
this.ref = virtualContext.ref;
this.zone = virtualContext.zone;
// ..
}
// .. методы для вызова change detection
}
// step-list.component.ts
@Component({
// ..
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class StepComponent extends VirtualComponent {
constructor(public appState: AppState,
public dataService: DataService,
private titleService: Title,
public virtualContext: VirtualContext
) {
super(virtualContext);
}
}
Answer the question
In order to leave comments, you need to log in
So far I've only found this:
http://stackoverflow.com/questions/39038791/inheritance-and-dependency-injection
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question