0
votes

As per ember document If any model hook in routes taking time to fetch data from server, ember will insert loading route. for example test-loading, at that time if we try to get current route name like this, it returns only the loading route. for example if sample route is getting too much of time to load, ember will transition into sample-loading until sample route resolved. Then again it will change to sample route. So at the time of sample-loading getCurrentRoute is returns the sample-loading. In my case I need to know the actual route name which is changed into -loading. I can't find any documentation in internet for doing this. If anyone know the way or idea to implement kindly share with me..

1
Can you remove -loading from the end of the route name string? Maybe I’m misunderstandingBuck Doyle

1 Answers

0
votes

The pragmatic approach is following:

let currentRoute = 'sample-loading';

if (currentRoute.endsWith('-loading')) {
  currentRoute = currentRoute.substring(0, currentRoute.lastIndexOf("-loading"));
}

console.log(currentRoute);