Search code examples
javascriptmongodbmeteoriron-router

How to use iron:router to create a separate link for each item in collection


I'm building a contacts app and I want to make it so that when a contact is selected it links to a page where it displays all the information for that particular person.

How would I go about implementing this? I was considering using a modal however this seems like the preferable option.


Solution

  • The iron router guide covers this and more:

    <template name="Post">
      <h1>Post: {{title}}</h1>
    </template>
    
    Router.route('/post/:_id', function () {
      this.render('Post', {
        data: function () {
          return Posts.findOne({_id: this.params._id});
        }
      });
    });
    

    If you are just starting with meteor though, you should consider flow-router.

    Start by reading the Meteor Guide: Routing.