When I add the injectable CameraChannelService into ngModule's provider array:
import { CameraChannelService } from './camera-channel.service';
@NgModule({
declarations: [
AppComponent,
BabylonWallpaperDirective,
MenuComponent,
WorksComponent,
LabsComponent,
ProfileComponent,
ActionBtnComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
routing
],
providers: [
CameraChannelService
],
bootstrap: [AppComponent]
})
Does it create a new instance for just that component? when I inject it into one of the NgModules declarations components?
import { Component, OnInit } from '@angular/core';
import {CameraChannelService} from '../camera-channel.service';
@Component({
selector: 'app-works',
templateUrl: './works.component.html',
styleUrls: ['./works.component.scss'],
providers: [CameraChannelService]
})
export class WorksComponent implements OnInit {
constructor(private cameraChannel: CameraChannelService) { }
ngOnInit() {
console.log(this.cameraChannel);
}
}