我有一个调节 true/false 的服务,它依赖于通过 *ngIf
显示和隐藏组件!目前,当我单击按钮时,服务呈现为 true,并且组件立即出现!
我需要它们仅在函数完全执行后才出现!也就是说,我需要页面滚动到顶部,然后只显示组件。
这是我的幻灯片组件,带有一个按钮,单击时告诉 content.service true
。
onGoToAbout(event) {
$(event.target.id).toggle();
$("#slideshow").slideUp(1500);
this.content.isContentShown = true;
}
<div class="explore-wrapper" (click)="onGoToAbout($event)" routerLink="/about">
当 content.service 为 true 时,标题组件出现:
<header class="sticky" *ngIf="header.isContentShown">
<div class="header-container">
<div class="header-left">
<h1>{{pageTitle}}</h1>
</div>
<div class="header-right">
<app-burger></app-burger>
</div>
</div>
</header>
<app-nav (sendTitle)="getTitle($event)"></app-nav>
我需要只有在页面滚动到顶部后才显示标题!
最佳答案
试试这个
$('#slideshow').slideUp(1500, function() {
this.content.isContentShown = true;
});
关于javascript - 如何在执行函数后显示组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57376505/