easyrtc
接收AppComponent
实例而不是ParentService
:
ChildService
如何获取import { Component, Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
class ParentService {
name = 'parent';
}
@Injectable({
providedIn: 'root'
})
class ChildService extends ParentService {
name = 'child';
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
logs = [];
constructor(childService: ChildService) {
this.logs.push('childService instanceof ChildService: ' + (childService instanceof ChildService));
this.logs.push('childService instanceof ParentService: ' + (childService instanceof ParentService));
this.logs.push('childService name: ' + childService.name);
}
}
实例?谢谢。