Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. private Boolean: BehaviorSubject<boolean>;
  2.  
  3. export class getDivStatus {
  4. public getTheBoolean(): Observable<boolean> {
  5. return this.theBoolean.asObservable();
  6. }
  7.  
  8. public setTheBoolean(newValue: boolean): void {
  9. this.theBoolean.next(newValue);
  10. }
  11. }
  12.  
  13. My component
  14.  
  15. ...
  16. import {getDivStatus } from /getDivStatus.service.ts
  17. ...
  18.  
  19. export class divCom implement oninit {
  20. constructor(private divservice: getDivStatus)
  21. ngOnInit() {
  22. booleanDiv = true;
  23. this.divservice.setTheBoolean(true);
  24.  
  25. if(anotehrcondition) {booleanDiv = false; this.divservice.setTheBoolean(false);}
  26.  
  27. }
  28.  
  29. app.compoennt.ts
  30.  
  31. import {librarytotest} from librarytotest;
  32.  
  33. @compoennt({
  34. ...})
  35.  
  36. export class AppCompoet implements oninit{
  37. ngoninit() {
  38. this.librarytotest.getboolean().subscribe({x => console.log(x)});
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement