javascript - Nested Routing Behavior for Ember.js -


can explain behavior of router , nested routes in ember.js?

what resulting url, routename, controller, route, , template?

app.router.map(function(){     this.resource('profile');      // url: /profile     // routename: profile     // controller: profilecontroller     // route: profileroute     // template: profile      this.resource('artists', function(){          // url: /artists         // routename: artists or artists.index         // controller: artistscontroller or artistsindexcontroller         // route: artistsroute or artistsindexroute         // template: artists or artists/index          this.resource('artists.artist', { path: ':artist_id' }, function(){              // url: /artists/:artist_id             // routename: artists.index or artist.index             // controller: artistsindexcontroller or artistindexcontroller             // route: artistsindexroute or artistindexroute             // template: artists/index or artist/index              this.resource('artist.tracks', function(){                  // url: /artists/:artist_id/tracks                 // routename: artists.tracks or artists.artist.tracks or artist.tracks                 // controller: artiststrackscontroller or artistsartisttrackscontroller or artisttrackscontroller                 // route: artiststracksroute or artistsartisttracksroute or artisttracksroute                 // template: artists/tracks or artists/artist/tracks or artist/tracks                  this.route('playing', { path: ':track_id' });                      // url: /artists/:artist_id/tracks/:track_id                     // routename: tracks.index                     // controller: tracksindexcontroller                     // route: tracksindexrouteroute                     // template: tracks/index             });         });     }); }); 

if see of code on github https://github.com/gerst20051/hns-wave/tree/master/src/stations

javascript file github https://github.com/gerst20051/hns-wave/blob/master/src/stations/js/app.js

this guide i'm referencing http://emberjs.com/guides/routing/defining-your-routes/

and copied app structure https://github.com/inkredabull/sonific8tr

how app structure looks

many in advance , assistance appreciated me , whole emberjs community on emberjs struggle bus!

you need remove dot notation nested routes. use artist instead of artists.artist.

your corresponding router be,

app.router.map(function() {   this.resource('profile');   this.resource('artists', function() {     this.resource('artist', { path: ':artist_id'}, function() {       this.resource('tracks', function() {         this.resource('playing', { path: ':track_id' });       })     });   }); }); 

you can use app.router.router.recognizer.names list of routes being mapped in router.

this give following urls, routes , controllers.

  • /profile - profileroute - profilecontroller
  • /artists - artistsroute - artistscontroller
  • /artists/1 - artistroute - artistcontroller
  • /artists/1/tracks - tracksroute - trackscontroller
  • /artists/1/tracks/1 - playingroute - playingcontroller

also note, each resource has nested resource gets implicit index route. eg:- artistsindexroute, artistindexroute, tracksindexroute, not playingindexroute because has no nested routes.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -