Open new link in Meteor + Blaze

I have some trouble I have a first page in Meteor My First Page and my second page and it in same folder with my first page enter image description here

My firts page html:

  <div class="container">
      <h1>Todo List</h1>
      <a href = "/secondPage">{{> test}}</a>
<template name="chuong">
      {{#each chuongs}}
        <li>{{Chuong_ID}}, {{Truyen_ID}}</li>

My firts page in javascript:

import { Template } from 'meteor/templating';
import { Chuong } from '../api/chuong.js';
import './doctruyen.html';

Template.chuong.helpers ({
    chuongs() {
        return Chuong.find({});

My second Page in html:


in first page, when I click items will show the second page.... Thanks for help!

1 answer

  • answered 2017-10-11 20:35 Dom Ramirez

    It's best to use a router to have multiple, linked pages in Meteor. While there are a few you could use, my preference (and a common standard) is iron:router.

    There are pretty good examples on the above-linked page and in the Iron Router Guide, but here are some entry-level concepts to get your mind around things:

    1. You don't need to put <body> tags everywhere. Any <body> tag in an HTML file will be inserted into all rendered pages by default. The same is true of <head> tags.
    2. Each "Page" needs a template (as you've successfully defined with Template#chuong). I like to put my templates all in their own HTML files, but you can put templates anywhere inside your "client" directory. You can also add common layouts which you'll read about in the Iron Router documentation.
    3. Each "Page" also needs a "Route", which can be defined in a javascript file anywhere in your project, excluding server-only directories (like the "server" and "private" folders, for example.

    Once the above is handled, you should be able to link between pages the same way you usually would, using standard anchor tags (href="/routename").