[英]Object.keys is not working in Angularjs2
我嘗試在 angularjs2 項目中使用<div>{{ objectkey.keys(numberOfComment['post_1']).length }} Comments</div>
但它拋出錯誤“無法讀取未定義的objectkey.keys(numberOfComment['post_1']).length
" 但它在 js 中工作(在控制台中打印)。
我試圖實現如上所述這個鏈接Unable to call Object.keys in angularjs
this.objectkey = { keys : Object.keys }
在 js 文件中。
<div>{{ objectkey.keys(numberOfComment['post_1']).length }} Comments</div>
html
改成:
this.objectkey = {
keys : function(){
return Object.keys(numberOfComment['post_1']).length
}
}
並在 html
<div>{{ objectkey.keys() }} Comments</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.