流星:没有路径可解决路径错误.如何在嵌套对象中访问单篇文章 [英] Meteor: There is no route for the path error. how to access SINGLE article within a nested object
本文介绍了流星:没有路径可解决路径错误.如何在嵌套对象中访问单篇文章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有10个对象类别"的数组,每个类别都有子对象,例如该类别中的帖子.这就是它的样子.
I have an array of 10 objects 'categories' and each category has sub objects such as posts within that category. This is how it looks.
我这样访问类别列表.
<template name="CategoriesMain">
{{#each articles}}
<li>
<a href="/unfiltered/{{_id}}"><h2>{{name}}</h2></a>
</li>
{{/each}}
</ul>
</template>
此链接
<a href="/unfiltered/{{_id}}"><h2>{{name}}</h2></a>
访问类别如下的帖子"列表
accesses the 'posts' list within the category which looks like this
<template name="CategoriesSingle">
<h1>This is a test</h1>
<ul>
{{#each articles}}
{{#each posts}}
<li>
<a href="/catsingle/{{_id}}"><h2>{{title}}</h2></a>
</li>
{{/each}}
{{/each}}
</ul>
</template>
该链接应该以类别
<a href="/catsingle/{{_id}}"><h2>{{title}}</h2></a>
问题:
我得到一个错误:路径:/catsingle/没有路径,当我尝试访问单个帖子时
I get the error: There is no route for the path: /catsingle/ when ever i try to access the SINGLE POST
即使我这样在我的route.js中也有
even though i have it in my routes.js like this
FlowRouter.route('/catsingle/:_id', {
name: 'catsingle',
action() {
BlazeLayout.render("AppLayout", {main: "CategoryArticleSingle"});
}
});
模板助手看起来像这样
Template.CategoryArticleSingle.helpers({
articles: function () {
var id = FlowRouter.getParam('_id')
return CategoryCollection.findOne({_id: id});
}
});
我如何在某个类别中成功发布单个帖子?
How can I successfully the single post within a category?
推荐答案
您的posts
数组没有_id
键,它具有ID
键.
Your posts
array doesn't have an _id
key, it has an ID
key.
尝试:
<a href="/catsingle/{{ID}}"><h2>{{title}}</h2></a>
这篇关于流星:没有路径可解决路径错误.如何在嵌套对象中访问单篇文章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文