I have a HomePage
page with a property shouldNavBeTransparent: boolean = true
which indicates if the navbar of the page should have a class="transparent
or not.
After the window has reached 90% of its height, I set the property shouldNavBeTransparent
to true.
My problem is that the property isn't being changed in the view. In the view, it's always false, while in the component, it's being changed.
This is my home.ts
file:
import {Component} from '@angular/core';
import {IonicPage} from 'ionic-angular';
@IonicPage({segment: "/"})
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
services: Array<{ icon: string, title: string, subhead: string, content: string }>;
shouldNavBeTransparent: boolean = true;
scrollHandler($event) {
this.shouldNavBeTransparent = ($event.scrollWidth * 0.9) < $event.scrollTop;
console.log(this.shouldNavBeTransparent);
}
}
The console.log
in scrollHandler
outputs true and false, which indicates it is changing:
The part where I check the property in my view is (home.html
):
<ion-header [class.transparent]="shouldNavBeTransparent">
The part where I trigger the scroll event:
<ion-content (ionScroll)="scrollHandler($event)">
Even when I write {{ shouldNavBeTransparent }}
all I get is true.
I'm using Ionic v3.19.1