samedi 3 janvier 2015

Ember-CLI - Multiple Dynamic Segments doesn't render the right template

Right now I am trying to set up nested routes that are dynamic segments. Such as /shop/:category/:item. Currently the router is set up as this:


In router.js:



Router.map(function() {
this.resource('shop', { path: '/shop' }, function(){
this.resource('products.index', { path: '/:category' }, function(){
this.route('product', { path: ':item' } );
});


If you are wondering why I have products.index, I had to put the ".index" at the end for it to pull the params from the URL. If I took out the index, I wouldn't be able to pull the dynamic segment from the URL in the route.




My file structure is as follows (only listing relevant files):



  • controllers

    • products

      • index

        • product.js



      • index.js





  • routes

    • products

      • index

        • product.js



      • index.js





  • templates

    • products

      • index

        • product.hbs



      • index.hbs

      • product.hbs






I put product.hbs template both on the inside of a index folder as well as outside. I also tried putting "templateName", "viewName", "renderTemplate: function(){ this.render('products/index/product') }" in the route, nothing seems to work.


It always resolves to the products template page, never to the product page. I turned the ember log resolver on, and it says:


[✓] template:products/index


[✓] template:products/index


[✓] template:products/index


[✓] template:products/product


[✓] template:products/product


[✓] template:products/product


[ ] view:products/index/product


[ ] view:products/index/product


[ ] view:products/index/product


[ ] view:products/index/product


[ ] view:products/index/product


[ ] view:products/index/product


[ ] view:products/index/product


Anyone have any idea on what is causing this? Template for product is very simple, just a "TEST" in hbs.





Aucun commentaire:

Enregistrer un commentaire