ember.js - How do I retrieve the path of a route? -


given following router setup:

app.router.map(function() {   this.resource('posts', function() {     this.route('new');     this.resource('post', { path: ':post_id' }, function() {       this.route('edit');     });   }); }); 

is possible obtain path of route?

fictitious example:

app.router.get('path', 'posts.new'); //=> "/posts/new" 

or model like:

app.router.get('path', 'post.edit', model); //=> "/posts/1/edit" 

try in console/dev tools:

app.router.router.generate(['posts.new']); 

this should output:

/posts/new 

and model:

app.router.router.generate(['post.edit'], postmodel); 

will output

/posts/1/edit 

thanks @milkywayjoe's reference! https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/helpers/link_to.js#l112-l117 :)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -