Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current url (including the part after hash) with Ember

I need to get current url from Ember as a "redirectTo" parameter. The parameter will be used to redirect users back to the same page after they login from other app. The url looks like

http://test.com/apps/#/tables/7

I've found this post to get currentPath/route from the application. It provides the current route name but I wonder how I can get the complete path including id from Ember. I have a nested route declaration looks like below.

App.Router.map(function() {
  this.resource('tables', function() {
    this.resource('table', { path: ':table_id' });
  });
});

Any suggestion is welcome. Thanks!

like image 792
wen Avatar asked Nov 18 '25 17:11

wen


1 Answers

Observe the currentPath in ApplicationController and update the current URL:

App.ApplicationController = Ember.Controller.extend({
  currentPathDidChange: function() {
    App.currentUrl = window.location.href;
  }.observes('currentPath')
});
like image 167
Panagiotis Panagi Avatar answered Nov 21 '25 07:11

Panagiotis Panagi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!