Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4830

Accessing query params in application route, or in application controller during setup

$
0
0

@normanhaze wrote:

I have a scenario that seems like it should be straight forward, but I just can’t get it working.

I have an app that relies on a query param in the application route, which determines which data to load throughout. Let’s call it “team”. When the app first loads, I want to check if a team query param exists. If it does, I want to save it to local storage, if not, I want to check local storage and see if they have a team id stored there, and if so, transition to it.

However, I can’t find a way to access the query params on initial load. There is no transition object passed to setupController in the application route that I can take them from. If I put the logic in a function in the application controller and then call it in setupController, this.team is still undefined when it is called.

I can get it to work by using run.later to run the setup after 1000ms, but this is far from idea. The other option is an observer, but that’s not best practice these days. Anyone got any suggestions?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4830

Trending Articles