I am fairly new to ionic so excuse my newbie question. I searched all over for a solution and tried different things none with success and I can’t figure what I am missing.
I have a button which calls a function on click which toggles a boolean variable true/false
<button class="button" (click)="activate();"><i class="icon-font-size"></i></button>
I than added ngClass on a div that will add or remove class basest on the boolean var value
<div class="text-settings" [ngClass]="{'open': active === true}">
...
</div>
In the TS file of the page I have
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
/*
Generated class for the SinglePost page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-single-post',
templateUrl: 'single-post.html',
})
export class SinglePostPage {
selectedItem: any;
active : boolean = false;
constructor(public navController: NavController, public navParams2: NavParams) {
this.selectedItem = navParams2.get('item');
}
activate() {
this.active = !this.active;
console.log(this.active);
}
}