【发布时间】:2019-07-17 12:44:42
【问题描述】:
在视图中我有这种情况:
<h3 *ngIf="show">{{users.result}}</h3>
在我的 TypeScript 逻辑中:
show=false; <----as a property
还有以下功能:
timeOut(seconds: number, value:boolean) {
value = true;
setTimeout(
function() {
value = false;
}.bind(this),
seconds
);
}
但是当我调用它时,像这样:
console.log(this.timeOut(3000, this.show));
属性“this.show”未定义,但作为参数传递的秒数有效。我遗漏了一些东西,我不知道是什么...有人可以帮忙吗?
【问题讨论】:
-
您想在
seconds之后切换show属性吗? -
console.log(this.timeOut(3000, this.show));应该返回undefined因为this.timeOut不返回任何内容
标签: javascript angular timeout