0
我确信之前已经回答了这个问题,所以我提前谦虚地道歉。在构造函数中为一个类设置一个全局变量Angular 2
我注意到,在构造函数中设置一个私有变量允许类的其余部分使用该变量。
EX:
constructor(private foo : bar) { }
...
later in code
...
this.foo
我的问题很简单 - 为什么这项工作?
(什么是角度和打字稿在后台做什么?)
你为什么不看看编译好的js文件? – echonax
我会下次。我很抱歉没有这样做事先 – Gabrielus
[成员属性和构造函数在angular 2 typecript中的语法]的可能重复(http://stackoverflow.com/questions/36683698/syntax-of-member-properties-and-constructors-in-角-2-打字稿) – Fiddles