[英]Left-hand side of assignment expression cannot be a constant or a read-only property in Angular2
Here's how my code looks like 这是我的代码的样子
this.timezones = moment.tz.names();
for(let timezone in this.timezones) {
this.timezones[timezone] = this.timezones[timezone] +' '+ moment.tz(this.timezones[timezone]).format('Z z');
}
I am getting the above mentioned error in line present inside for loop, I didn't get this error until i upgraded to angular2.1 我在for循环中的行中收到上述错误,直到升级到angular2.1,我才收到此错误
is there any other way to access the elements of timezones variable to make it writable as well? 还有其他方法可以访问timezones变量的元素以使其可写吗?
as per docs of moment timezone 根据时区的文档
moment.tz.names(); // String[]
gives string array. 给出字符串数组。
now, 现在,
this.timezones[timezone] is undefined.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.