I have two modules:
1st:
@NgModule({
imports: [
BrowserModule,
FormsModule,
SharedModule.forRoot()
],
declarations: [
FirstComponent
],
bootstrap: [ FirstComponent ]
})
export class AppModule { }
2nd:
@NgModule({
imports: [
BrowserModule,
FormsModule,
SharedModule.forRoot()
],
declarations: [
ScndComponent
],
bootstrap: [ ScndComponent ]
})
export class AppModule { }
and shared module with static .forRoot()
@NgModule( {} )
export class SharedModule {
static forRoot() {
return {
ngModule : SharedModule,
providers : [DumyService]
}
}
}
My DumyServise has some prop 'paramd' and I want to watch changes through modules
@Injectable()
export class DumyService {
paramd : string;
}
In both components of modules (1st and 2nd) I have
private ds: DumyService
in constructors.
Then, let's say I have some onclick method in some component of first module component, that changes
clickToChangeParam() {
this.ds.paramd = 'new value';
}
And I want to have this changes in both modules. How can I handle that?