【发布时间】:2014-05-15 20:41:56
【问题描述】:
App.Controller = Ember.ObjectController.extend({
timerStart: function () {
this.timer = setInterval(this.ctimer, 1000);
},
timerEnd: function () {
this.clearInterval(this.ctimer);
},
ctimer: function () {
var d = new Date();
document.getElementById("timeBar").innerHTML = d.toLocaleTimeString();
}
});
在 ember.js 中,我调用 timerEnd 函数时 clearInterval 函数不起作用。
解决此代码问题的正确方法是什么。谢谢。
【问题讨论】:
-
错别字,应该是:this.clearInterval(this.timer);
标签: javascript ember.js setinterval clearinterval