vendredi 27 mai 2016

How do I access the variable of a dynamic route in EmberJS

I've done

ember g route auth
ember g route auth/pending

Which then gave me :

app/
  routes/
    auth/
      pending.js
    auth.js

and my router has

  this.route('auth', function() {
    this.route('pending', { path: '/pending/:steamid/:token'});
  });

Which everything is fine, when I visit

http://localhost:4200/auth/pending/1/2

The page loads, but how do I access :steamid and :token outside of the model.

I'd like to use it so that I can set values in my session service

Like:

import Ember from 'ember';

export default Ember.Route.extend({
  session: Ember.inject.service(),

  steamID: this.get(// Params Some How),
  token: this.get(// Params some How)

  thing(params) {
    this.get('session').set('tokenID', token),
    this.get('session').set('steamID', steamID)
  }
});

^^ Pseudo code to express what I'm trying to accomplish.




Aucun commentaire:

Enregistrer un commentaire