【发布时间】:2016-06-18 07:11:56
【问题描述】:
将变量设置为全局(临时)对于调试很有用。我们如何将 Angular 组件中的变量标记为全局变量,以便它可以在浏览器 Web 控制台中以交互方式使用? (我不想只使用 console.log 记录变量,而是能够在 javascript Web 控制台中与变量进行交互和使用。
@Component({..})
export class App {
myvar = null;
constructor() {
this.myvar = "Hello World";
}
// How do we make myvar global? (temporarily)
// so that we can use it in the web console to play around with it
// It's a simple string here but it could be a complex object
// that we may want to inspect interactively.
}
【问题讨论】:
标签: typescript angular