We are porting our old app to Ember and in the process of doing so we made a few changes to the URL structure. The main one is that we are not using hash routes anymore. In the past, our routes would look like http://domain.com/#profile/some_id/
(singular, id, and with a hash) and on the new one it will be something like http://domain.com/profiles/username/
(plural, username and without the hash).
We can handle the plural/singular change by creating the singular route and redirecting the user from the singular to the plural.
import Ember from "ember";
export default Ember.Route.extend( {
model( params ) {
return this.get( "store" ).findRecord( "profile", params.id );
},
afterModel( model ) {
this.transitionTo( "profiles", model.get( "username" ) );
},
} );
Without the hash, redirecting from singular and id to plural and username works. With a hash, if I add a /
after the hash (as in /#/profile/id
), it also works. But with the old routes, without the extra /
the route is not redirecting as it should.
Is there a way of telling Ember that /#profile/
is also a hash route?
Aucun commentaire:
Enregistrer un commentaire