Suppose you have an Angular service (ZombieService
) which, for example, monitors an other service.
And, ZombieService
isn't injected anywhere DEMO
The problem is that, when you do not inject a service anywhere, that service is completely ignored (not executed). The solution is to inject it into, for example, AppComponent
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.scss' ]
})
export class AppComponent {
constructor(zombieService: ZombieService) {}
...
}
Although this works, I was wondering if there isn't a better solution for this. Any suggestions?