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

Ember get current route name

$
0
0

@hschillig wrote:

So I'm trying to get the current route name (to make sure it doesn't equal a certain route to show this section of the layout).. Right now, I'm using something like this:

import Ember from 'ember';

export default Ember.Controller.extend({
  routing: Ember.inject.service('-routing'),

  queryParams: ['fname', 'lname', 'page', 'perPage', 'sort', 'dir', 'q'],
  page: 1,
  fname: '',
  lname: '',
  q: '',

  isSearching: function() {
    var currentRoute = this.get('routing').get('currentRouteName');
    console.log(currentRoute);
    if ((this.get('q') !== '' || this.get('fname') !== '' || this.get('lname') !== '') || currentRoute == 'contracts.index') {
      return true;
    }

    return false;
  }.property('q', 'fname', 'lname')
});

This doesn't seem to update quick enough when I navigate to a different page. I'm on contracts.index and then I click a link that should lead to contracts.contract.index which it does, but the routing service doesn't seem to update quick enough.. it still says I'm on contracts.index and then if I do a simple page refresh, THEN it shows contracts.contract.index. Is there another way around this?

I do a console.log(this.get('routing')) and it SHOWS that the currentRouteName property DOES equal contracts.contract.index, but whenever I do a .get('currentRouteName') it still says contracts.index which makes no sense.. when i do that console log it tells me something else until I perform the .get() on the property.

Thank you for any help!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4835

Trending Articles