【发布时间】:2016-10-04 02:03:03
【问题描述】:
我不确定这是否是这个问题的地方,但有人告诉我代码审查不适合它。
我刚刚学习 Angular 2 和 Typescript,所以正在学习以下教程:
https://angular.io/docs/ts/latest/tutorial/toh-pt4.html
在第三部分和第四部分之间,heroes 变量在 app.component.ts 中的声明从:
export class AppComponent {
heroes = HEROES;
}
到:
export class AppComponent {
heroes: Hero[];
}
我知道第一个将其设置为英雄数组的常量,但为什么第二个使用冒号而不是将其设置为空数组?
将第二个更改为= 实际上会引发表达式预期错误,所以基本上我只是想了解两者之间的区别。
【问题讨论】:
标签: angular typescript