samedi 4 avril 2015

How do I output the value of dynamic segments onto a page with Ember?

This is my app/router.js file:



export default Router.map(function() {
this.route("food");
this.route("foodtype", { path: '/food/:food_name' });
});


This is routes/foodtype.js:



export default Ember.Route.extend({
model: function (params) {
return params;
},
serialize: function (model) {
return { food_name: model.get('food_name') };
}
});


Hence, if I go to food/pizza in my Ember application, Ember will load the above file, with food_name equal to pizza.


My question is, how do I use this value (pizza) in my handlebar file? It currently looks like this:



<h1>Mmm, ...</h1>


I want to put pizza there inside that <h1> tag.


How would I do this?





Aucun commentaire:

Enregistrer un commentaire