[英]Object.keys is not working in Angularjs2
I tried using <div>{{ objectkey.keys(numberOfComment['post_1']).length }} Comments</div>
in angularjs2 project but it is throwing error "cannot read property of undefined objectkey.keys(numberOfComment['post_1']).length
" but it is working in the js (prints in the console).我尝试在 angularjs2 项目中使用<div>{{ objectkey.keys(numberOfComment['post_1']).length }} Comments</div>
但它抛出错误“无法读取未定义的objectkey.keys(numberOfComment['post_1']).length
" 但它在 js 中工作(在控制台中打印)。
i tried to implement as mentioned this link Unable to call Object.keys in angularjs我试图实现如上所述这个链接Unable to call Object.keys in angularjs
this.objectkey = { keys : Object.keys }
in the js file. this.objectkey = { keys : Object.keys }
在 js 文件中。
<div>{{ objectkey.keys(numberOfComment['post_1']).length }} Comments</div>
in html <div>{{ objectkey.keys(numberOfComment['post_1']).length }} Comments</div>
html
Change to:改成:
this.objectkey = {
keys : function(){
return Object.keys(numberOfComment['post_1']).length
}
}
and in the html并在 html
<div>{{ objectkey.keys() }} Comments</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.