Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Boolean: BehaviorSubject<boolean>;
- export class getDivStatus {
- public getTheBoolean(): Observable<boolean> {
- return this.theBoolean.asObservable();
- }
- public setTheBoolean(newValue: boolean): void {
- this.theBoolean.next(newValue);
- }
- }
- My component
- ...
- import {getDivStatus } from /getDivStatus.service.ts
- ...
- export class divCom implement oninit {
- constructor(private divservice: getDivStatus)
- ngOnInit() {
- booleanDiv = true;
- this.divservice.setTheBoolean(true);
- if(anotehrcondition) {booleanDiv = false; this.divservice.setTheBoolean(false);}
- }
- app.compoennt.ts
- import {librarytotest} from librarytotest;
- @compoennt({
- ...})
- export class AppCompoet implements oninit{
- ngoninit() {
- this.librarytotest.getboolean().subscribe({x => console.log(x)});
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement