【发布时间】:2022-01-20 18:51:39
【问题描述】:
我正在构建一个 Angular 应用程序,并且我试图在字符串数组的每个 forEach 迭代中插入一个字符串的值。 (quotesData 是我从中获取值的字符串数组)
我的函数如下所示:
export() {
this.quotesData.forEach(element => {
this.quote = element;
this.wait(1000); \\ <- manually written function to postpone next line execution for 1s
console.log(this.quote);
});
}
问题是 {{quote}} 的 HTML 插值中的值在最后一次迭代结束之前不会更新。但是,this.quote 的值会在每次迭代后正确更新并显示在控制台和调试器中。
【问题讨论】:
标签: javascript html angular typescript