Does the Ionic3 ngClass binding style need to be triggered by a click?

originally intended to use the ionScroll event in < ion-content > of Ionic3 to change the style of < ion-header > , but the event started with the style unchanged. But if I add a button to header, the style changes with one click.

related codes

HTML

<ion-header [ngClass]="{"transparent-header": transparentHeader}">
  <ion-navbar color="light">
    <ion-title></ion-title>
    <ion-buttons end>
      <button icon-button (click)="goToEdit()"></button>
    </ion-buttons>
  </ion-navbar>
</ion-header>
<ion-content (ionScroll)="scrollEvent($event)"></ion-content>

TypeScript

transparentHeader: boolean = true;

scrollEvent(ionContent) {
  let opacity = 1 - (150 - ionContent.scrollTop) / 150;
  this.transparentHeader =  opacity >= 1 ? false : true;
}

goToEdit() {
  console.log("Go to edit.")
}

originally expected the page to slide down a certain distance, the transparent-header style of header will be automatically removed, but now you have to slide down and click the edit button to remove it, while the edit button contains only one statement output from the console.

Picture

No downward sliding effect is shown in the following figure:

clipboard.png

:

clipboard.png

:

clipboard.png

Apr.01,2021

just read the official documents and found a solution.

Scroll events happen outside of Angular's Zones. This is for performance reasons. So if you're trying to bind a value to any scroll event, it will need to be wrapped in a zone.run ()
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf2413-31dfc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf2413-31dfc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?