@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 tocontracts.contract.index
which it does, but the routing service doesn't seem to update quick enough.. it still says I'm oncontracts.index
and then if I do a simple page refresh, THEN it showscontracts.contract.index
. Is there another way around this?I do a
console.log(this.get('routing'))
and it SHOWS that thecurrentRouteName
property DOES equalcontracts.contract.index
, but whenever I do a.get('currentRouteName')
it still sayscontracts.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