Angular - Services and Dependency Injection
Given this Angular component code:
If two instances of
@Component({
selector: 'app-example',
template: `{{counter}}
`,
providers: [CounterService]
})
export class ExampleComponent {
counter = 0;
constructor(private counterService: CounterService) {
this.counter = this.counterService.increment();
}
}If two instances of
app-example are rendered, what will be the value of counter in each?