流星:显示与车把客户端嵌套对象
Meteor : display with handlebars client side nested object
>我有来自助手的 JSON:
{
"perms": [
{
"userId": "rA5s5jSz7q9ZSCcNJ",
"perms": [
{
"moduleName": "Gallery",
"container": {
"ImageUpload": {
"addImage": false,
"modifyImage": false,
"removeImage": false
},
"Article": {
"readArticle": false,
"createArticle": false,
"modifyArticle": false,
"removeArticle": false,
"archiveArticle": false
}
}
}
]
},
{
"userId": "RrmynmmngJEMsRRpk",
"perms": [
{
"moduleName": "Gallery",
"container": {
"ImageUpload": {
"addImage": false,
"modifyImage": false,
"removeImage": false
},
"Article": {
"readArticle": false,
"createArticle": false,
"modifyArticle": false,
"removeArticle": false,
"archiveArticle": false
}
}
}
]
}
]
我的JS是:
'userWithRights':function() {
Meteor.call('genereObjectPermission',function(err, resp){
Session.set('responseServer', resp);
});
responseServer = Session.get('responseServer')
return _.map(responseServer, function(value, key) { return {key: key, value: value}; })
},'iterateInValue':function(){
return _.map(this, function(value, key) { return {key: key, value: value}; })
}
和我的HTML代码(多次试验的结果):
{{#each userWithRights}}
<p> {{key}} </p>
{{#each value}}
<li>{{this.userId}}</li>
{{#each perms}}
<li><li>{{moduleName}}</li></li>
{{#each test58}}
<li><li><li>{{key}}</li></li></li
{{/each }}
{{/each}}
{{/each}}
{{/each}}
所以,我对车把有点迷茫,当我必须迭代Object { key : value }
我很难成功时,但是当我必须在嵌套在其他对象中的对象中迭代时,我不能:
{"container": { "ImageUpload": { "removeImage": false }}}
我尝试得到这样的结果:
- rA5s5jSz7q9ZSCcNJ
画廊
图片上传
- 添加图像 : 真
- 修改图像:假
- 删除图像:假
- 品
- 阅读文章 : 真
- 创建文章 : 假
- 修改文章:假
您希望
使用 #with 帮助程序并使用@key访问密钥:
{{#each userWithRights}}
<p> {{key}} </p>
<ul>
{{#each value}}
<li>{{this.userId}}</li>
{{#each perms}}
<li>{{moduleName}}</li>
{{#with container}}
{{#with ImageUpload}}
<li>{{@key}}</li>
{{/with}}
<ul>
{{#each ImageUpload}}
<li>{{@key}}: {{this}}</li>
{{/each}}
</ul>
{{#with Article}}
<li>{{@key}}</li>
{{/with}}
<ul>
{{#each Article}}
<li>{{@key}}: {{this}}</li>
{{/each}}
</ul>
{{/with}}
{{/each}}
{{/each}}
</ul>
{{/each}}
希望对您有所帮助!
相关文章:
- 套接字服务器向客户端广播,但不从两者接收
- 无法从客户端发出套接字消息
- 套接字io客户端网络::ERR_CONNECTION_REFUSED
- 在通过套接字发送到客户端之前压缩中等大小的javascript数组是否值得
- 如何检测套接字何时在客户端上打开
- 使用sails.js中的beforeConnect函数获取客户端套接字
- 筛选客户端上的嵌套对象
- Nodejs - 让客户端套接字在 5 秒超时后重试
- Java 脚本 Web 套接字客户端无法正常工作
- sails 客户端(浏览器)如何侦听从不同端口发出(爆破)的套接字消息
- 获取嵌套在聚合物纸张对话框中的自定义Web组件内内容的客户端高度
- 运行 Web 套接字客户端编程
- 在客户端对 Web 套接字进行编程
- 流星:显示与车把客户端嵌套对象
- 套接字 - 客户端站点上不显示任何数据
- 如何使用php从客户端获取套接字的headers请求
- 如何在客户端生成父/子嵌套
- 我如何断开套接字服务器端和客户端在套接字.io 1.0
- 从客户端添加套接字发出
- 如何在客户端要求套接字流