Hi! I'm a relative Ember with TypeScript newbie, on Ember 5.0.0. I've been trying to figure out how to make a component that simply returns to the previous route with the same dynamic parts of the url (say i click from user/123 to article/93, how can i click a 'Back' button from article/93 and go to user/123, if that makes sense?). The issue I've been having is that my app is running in a Google Apps Script sidebar sandbox where browser history APIs don't work. I have a component that serves as the actual button (no template yet, been trying to nail logic down, https://github.com/bluelinden/articleman/blob/e62ddc61c451a7e26932e6ab9f6721b9640e14d6/frontend/app/components/back-button.ts) and a service (https://github.com/bluelinden/articleman/blob/01f90729afa6ed30c4b97022f449283ec31a9277/frontend/app/services/route-history.ts) that keeps track of the navigation stack. If nothing else, could I get some advice on how to do this in a robust way?
#Resources / tips on how to make an in-app 'Back' button?
1 messages · Page 1 of 1 (latest)
hello! and welcome!
does history.back() work?
My app uses locationType: 'none' (https://guides.emberjs.com/release/configuring-ember/specifying-url-type/), so sadly I can't use history APIs. Sorry I didn't clarify that and avoid using URL terminology in my original post. That's why I had the service.
why avoid the URL? / how come the history APIs don't work?
anywho, looking at your code, it doesn't look like you're too far off
I think you'd probably want a stack of URLs rather that route metadata (names + params)
so you'd have an array of strings that you could pop off and transitionTo
i just have no idea how to get those urls in the first place, is there a routerservice method?
YOO thanks! that's exactly what i need! i'll think about this tomorrow when it isn't 11:44 PM in my timezone. thank you so much for the help!