2016-11-07 15 views
0

這裏是我的代碼看起來像左邊不能是一個常數或Angular2一個只讀屬性

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'); 
} 

我在目前在for循環線獲得上述的錯誤,我沒有得到這個錯誤,直到我升級到angular2.1

是否有任何其他方式訪問timezones變量的元素,使其可寫?

+0

哪裏是'timezones'? 'let timezones'似乎是別的,因爲它似乎與'for'循環代碼的方法相同。 –

+0

timezones是類屬性..和訪問像this.timezones –

+0

這將是偉大的,如果你可以更新你的問題,使問題的核心部分清楚;-) –

回答

0

按照docs of moment timezone

moment.tz.names(); // String[] 

給出字符串數組。

現在,

this.timezones[timezone] is undefined. 
相關問題