Joshua Terrill
Joshua Terrill

Reputation: 2017

Iron Router Mongo ID Lookup

I am inserting some information into a mongo collection using this: id = Meteor.uuid(); subject = $(".msg_textarea").val(); url = "http://mysite.net/" + id; message.insert({ id: id, subject: subject, url: url, });

Now what I would like to do is set up an iron-router mapping so that when I visit http://mysite.net/id/:id it displays the subject from the collection.

Upvotes: 0

Views: 88

Answers (1)

Tarang
Tarang

Reputation: 75945

In your route you could have

this.route('templatename',
    path: '/id/:id'
    data: function() {
       return message.findOne({_id: this.params.id});
    }
});

Then in your template you could use {{subject}}

Upvotes: 1

Related Questions