I am sharing data across two sibling components using an injectible. In my injectible I am using an observable like this:
@Injectable()
export class DatasService {
message: Observable<string> = new Observable<string>();
changeMessage(){
this.message.next('Arpita'); //Property next doesn't exist
}
changeMessage2(){
this.message.next('Ankan');
}
}
But then when I am using Subject in place of Observable it works fine. I want to use Observable instead of Subject, so is it possible? I am new to reactive programming, and I am confused.
use a global variable instead of injectible. so that you can access them through out your project. 1.create a property in DTO. 2.import in that component where you want to use. 3.create a variable of that type in constructor's parameter. 4.access with the use of that variable.