I am in the need to set a value (variable) and get change after performing some specific task.
I would like to share my system environment, which is as below-
******************************************************
Your system information:
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-beta.10
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
ios-deploy version: Not installed
ios-sim version: 5.0.8
OS: OS X Yosemite
Node Version: v6.2.2
Xcode version: Xcode 7.2 Build version 7C68
******************************************************
I wanted to use setter and getter to get this task done, see what i did-
mypage.ts-
import {NavController, NavParams, Content} from 'ionic-angular';
export class ListPage {
constructor(private navCtrl: NavController, navParams: NavParams) {
this.counter = 0;
}
public counter;
getCounter(){
return this.counter;
}
setCounter(count) {
this.counter = count;
// console.log(this.counter);
}
}
and this is html template as-
<div *ngIf= "( getCounter()== '0')">
.....
...
..
...
.....
</div>
<div (click)= (setCounter(getCounter()+1))
</div>
some= line of codes
....
....
....
on bottom
<div ( setCounter(0))>
</div>
I am able to get the value which is 0, but don't know how to set it. I want to set value without (click) even i have used click but i don't know how to do without click.
here are list of source URL which I have seen-
- How i can get input value within ionic 2 in my Component?
- Angular 2 call a function/method when an event is emitted
- How to call another components function in angular2
List 2 was a little bit useful but can't help me out.
Hope for help