我正在使用跨多个组件的服务,每个组件都在其自己的提供程序数组中提供给组件。
我很想知道哪些组件正在使用服务的哪些实例,因为我正在做一些涉及传递它们的实验。
是否有任何内置方法可以让我访问创建的服务实例的 ID?例如,??
下面的代码片段中的替换是什么?
@Component({
selector: 'app-component1',
templateUrl: './component1.component.html',
providers: [SearchService]
})
export class Component1 {
constructor(
public searchService: SearchService,
) {
console.log('The instance Id of searchService is...' + '??');
}