listen change value of property set by service subscribing angular 6

40 views Asked by At

change height scroll when full screen and (vertical - horizontal) where settings property have this values

so I try detect change (previous and current) value of property object set by service subscribing angular 6

 pageService.settingesSubject$.subscribe(data=>{
  if(data != undefined){
    if(this.settings != undefined){
      if(this.settings.menu != data.menu){
        data.menu =="horizontal"? this.height -= 56:this.height += 56;
      }
    }else{
        data.menu =="horizontal"? this.height -= 56:null;
    }
    this.settings=data;
  }
})

 pageService.isFullScreenSubject$.subscribe(data=>{
  if(data != undefined){

    if(this.isfirstChangeFullScreen){
      data? this.height += 85:null;
    }else{
      if(this.isFullScreen != data){
        data? this.height += 85:this.height -= 85;
      }
    }
    this.isfirstChangeFullScreen= false
    this.isFullScreen =data;
  }
})


---------
   isfirstChangeFullScreen:boolean=true;
  isFullScreen:boolean=false;
  height:number=465;
 @ViewChildren(PerfectScrollbarDirective) pss: 
                    QueryList<PerfectScrollbarDirective>;
      @ViewChild('backToTop1') backToTop:any; 

  public scrollToTop() {
this.pss.forEach(ps =>{
    ps.scrollToTop(0,250);
    });
  }
     public onPsScrollY(event){   
     (event.target.scrollTop > 300) ? 
     this.backToTop.nativeElement.style.display 
      = 'flex' : this.backToTop.nativeElement.style.display = 'none';
       }
       ngAfterViewInit(){
      this.backToTop.nativeElement.style.display = 'none';  
     }  
1

There are 1 answers

0
ahmad srhan On

send data from parent component where i get it in constructor