How to access the params in controller ember.js -


this router.js code.

this.route('contact',{'path': '/contact/:chat_id'}); 

and route.js code.

model(params) {    return this.store.findrecord("chat", params.chat_id) }, 

and controller.js code , can use this. shows error null value please me. how use params in controller

recordchat: function() {    var chat = this.get(params.chat_id)    ember.rsvp.hash({     offer_id: chat,   }) } 

in route.js, need call setupcontroller function this:

setupcontroller(controller, model) {     this._super(...arguments);     controller.set('chat', model); } 

now have access in controller calling:

recordchat() {    const chat = this.get('chat');    //  if don't call setupcontroller function, do:    // const chat = this.get('model') or this.get('model.id') if want id } 

update:

see working twiddle here


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -