lundi 25 avril 2016

Ember: Reuse nested route in different parents

I wanted to know how to reuse a nested route in different parent route. For example:

Template routeA: -> routeX

Template routeB: -> routeX

Router.map(function() {

  this.route('routeA', function(){
    this.route('routeX', {resetNamespace:true});
  });

  this.route('routeB', function(){
    this.route('routeX', {resetNamespace:true});
  });

})

I need to use to show routeX inside the current parent. In the example always shows the routeB when I use

I have 2 aproax to solution:

1) Put 1 child route in routeA and other in routeB:

Router.map(function() {

      this.route('routeA', function(){
        this.route('routeX');
      });

      this.route('routeB', function(){
        this.route('routeX');
      });

})

and use and but in this aproax I have a duplicate code.

2)

router.map(function() {
    this.route('*wildcard', function(){
       this.route('routeX', {resetNamespace:true});
    });
})

this option works but in the url appear "undefined" http://...undefined/routeX

Any idea? Thanks




Aucun commentaire:

Enregistrer un commentaire