Angular6 侦听更改订阅服务的属性集的值
当全屏和(垂直-水平)where settings属性具有此值时更改高度滚动 所以我尝试检测订阅服务的服务设置的属性对象的更改(以前和当前)值Angular6 侦听更改订阅服务的属性集的值,angular6,Angular6,当全屏和(垂直-水平)where settings属性具有此值时更改高度滚动 所以我尝试检测订阅服务的服务设置的属性对象的更改(以前和当前)值 pageService.settingesSubject$.subscribe(data=>{ if(data != undefined){ if(this.settings != undefined){ if(this.settings.menu != data.menu){ data.menu =="h
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';
}
pageService.SettingsSubject$.Subject订阅(数据=>{
如果(数据!=未定义){
如果(this.settings!=未定义){
if(this.settings.menu!=data.menu){
data.menu==“水平”?this.height-=56:this.height+=56;
}
}否则{
data.menu==“水平”?this.height-=56:null;
}
此参数。设置=数据;
}
})
pageService.isFullScreenSubject$.subscribe(数据=>{
如果(数据!=未定义){
如果(此.isfirstChangeFullScreen){
数据?this.height+=85:空;
}否则{
if(this.isFullScreen!=数据){
数据?this.height+=85:this.height-=85;
}
}
this.isfirstChangeFullScreen=false
this.isFullScreen=数据;
}
})
---------
isfirstChangeFullScreen:boolean=true;
isFullScreen:布尔值=假;
高度:数字=465;
@ViewChildren(PerfectScrollbarDirective)pss:
查询列表;
@ViewChild('backToTop1')backToTop:任何;
公共滚动totop(){
this.pss.forEach(ps=>{
ps.scrollToTop(0250);
});
}
公共服务(活动){
(event.target.scrollTop>300)?
this.backToTop.nativeElement.style.display
='flex':this.backToTop.nativeElement.style.display='none';
}
ngAfterViewInit(){
this.backToTop.nativeElement.style.display='none';
}
从父组件发送数据,我在构造函数中从父组件获取数据你能把你的帖子改写成一个实际问题吗?我不明白你在问什么,也许可以提供一些例子?我解决了谢谢如果问题解决了你可以把你的解决方案作为答案发布对不起,我是堆栈溢出的新手