Quantcast
Viewing all articles
Browse latest Browse all 4826

How to pass value from Router to some service?

@collegeimprovements wrote:

I need to access the value of currentUrl in one of my service.
For that we have following code:

const Router = Ember.Router.extend({
  location: config.locationType,
  rootURL: config.rootURL,

  didTransition: function() {
    this._super(...arguments);

    Ember.run.once(this, function() {
      console.log(`GIVES NAME OF CURRENT ROUTE: ${this.currentRouteName}`);  // Gives just routes
      console.log(`GIVES CURRENT URL WITHOUT HOST: ${this.get('url')}`); // Gives current URL
      console.log(`GIVES FULL URL: ${window.location.href}`);
    });
  }


});

I need to get the value of that fullUrl in one of my services. How can I do this ?

Also, is there any other better way for getting the correct value of currentURL in services/controller?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles