0
我使用流星創建了一個投資組合,併成功地循環了數據庫中的投資組合項目(使用燈具創建)。我遇到問題,試圖按一個項目並轉到它的特定頁面。我確信這很簡單,但我對流星很新。流星路線到個人頁面
我的結構如下:
收集:
PortfolioItems = new Mongo.Collection('portfolioItems');
公開:
Meteor.publish('portfolioItems', function() {
return PortfolioItems.find();
});
組合頁模板:
<template name="portfolio">
<h1>Portfolio</h1>
<hr>
{{#each portfolioItems}}
{{> portfolioItem}}
{{/each}}
<a href="{{pathFor 'home'}}">Go Back Home</a>
</template>
組合頁面模板Helpe R:
Template.portfolio.helpers({
portfolioItems: function() {
return PortfolioItems.find({});
}
});
組合項模板:
<template name="portfolioItem">
<h1>{{title}}</h1>
</template>
最後我的路線:
Router.configure({
layoutTemplate: 'layout',
loadingTemplate: 'loading',
notFoundTemplate: 'notFound'
});
Router.route('/', function() {
this.render('home');
}, {
name: 'home'
});
Router.route('/about', function() {
this.render('about');
});
Router.route('/portfolio', function() {
this.render('portfolio');
}, {
name: 'portfolio',
waitOn: function() {
return Meteor.subscribe('portfolioItems');
}
});
如何{{#each portfolioItems}}在這個工作 \t {{> portfolioItem}} {{/每}} – Dileet 2015-02-12 02:04:27
的網址最終被本地主機: 3000 /組合/ this._id – Dileet 2015-02-13 04:31:44