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

Obtaining the current url using the Router service

$
0
0

@therealbenhogan wrote:

Hi,

I want to grab the (full) url in my (page) router so I can pass it to my server in order to produce navigation breadcrumbs.

In the page route, I am injecting the Router service, and am trying to grab the currentURL in the setupController method - but this just returns null.

import {inject as service} from '@ember/service';

Router …

export default Route.extend({
    router: service(),
    ...etc.etc

   setupController(controller,model) {
       this._super(controller,model);
       console.log(this.router.currentURL); // returns null
       console.log(this.router.get('currentURL')); // returns null
   }
});

Looking at the object (this.router) in the console I’m not sure why I can’t get this value?

Many thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4836

Trending Articles