How do I retrieve the path of a route?

后端 未结 1 1588
渐次进展
渐次进展 2020-12-10 08:45

Given the following Router setup:

App.Router.map(function() {
  this.resource(\'posts\', function() {
    this.route(\         


        
相关标签:
1条回答
  • 2020-12-10 09:04

    Try this in your console/dev tools:

    App.Router.router.generate(['posts.new']);
    

    this should output:

    /posts/new
    

    And with a model:

    App.Router.router.generate(['post.edit'], postModel);
    

    will output

    /posts/1/edit
    

    Thanks to @MilkyWayJoe's reference! https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/helpers/link_to.js#L112-L117 :)

    0 讨论(0)
提交回复
热议问题