empty params variable in ember

后端 未结 1 1839
星月不相逢
星月不相逢 2020-12-11 22:33

So I\'ve set up a router and some routes, and this works for the most part. when I load #/contacts/123 (or whatever) the ContactIndexRoute returns an empty params object.

相关标签:
1条回答
  • 2020-12-11 23:07

    Params are only passed to route which defines the slug. Meaning if you define a slug on the resource it only exists on the resource, and not its routes. If it's defined on a route under a resource it only lives on that route.

    CallMonitor.ContactRoute = Ember.Route.extend({
        model: function(params){
            return  this.store.find('contact', params.contact_id);
        },
        renderTemplate: function(){
            this._super(this, arguments);
            this.render('contact', {
                outlet: 'points',
                into: 'contacts',
                controller: 'contactsIndex'
            })
        },
        setupController: function(controller, contact) {
            controller.set('contact', contact);
        }
    });
    
    0 讨论(0)
提交回复
热议问题