I'm currently experimenting with the CSS animation feature to display and conceal the angular material toolbar in this demonstration.
Inside the application component, the hide
attribute is toggled at intervals as shown below:
hide:boolean = false
show() {
this.hide = !this.hide;
console.log(`Hide? ${this.hide}`)
}
constructor() {
this.show.bind(this)
setInterval(this.show, 2000)
}
The respective CSS style for the mat-toolbar
element is defined like this:
<mat-toolbar [ngClass]="hide ? 'hideToolbar' : 'showToolbar'"
class="hideShowToolbar"><h2>Material Baseline</h2>
</mat-toolbar>
Despite using the ngClass
directive, the toggle between hideToolbar
and showToolbar
does not work. Any ideas?
An alternative approach involving an Observable
was also attempted: