【发布时间】:2017-12-13 16:20:05
【问题描述】:
我在我的 ionic3 应用程序中使用 ng2-simple-timer。
这是来自 repo 的代码:
counter: number = 0;
timerId: string;
ngOnInit() {
this.timerId = this.st.subscribe('5sec', () => this.callback());
}
callback() {
this.counter++;
}
simpletimer 将创建计时器名称并每隔 'number' 秒打勾。
回调将返回计数器值(0、1、2、3、4、5、6等)
我的问题是什么?
我想定义唯一的uniquecounterName: number = 0;,因为我有不止一个计时器。
我的结果是什么:
- return uniquecounterName(0,1,2,3,4,5,6, etc..)
- return otheruniquecounterName(0,1,2,3,4,5,6, etc..)
换句话说,callback() 函数必须返回预定义的唯一变量名,例如 this.counter
callback(var) {
var++;
}
这个不起作用,因为我想在我的视图中使用 var。 ....
【问题讨论】:
标签: javascript angular ionic3