¿Cómo puedo usar las rutas, pero no cambiar la URL?

I am building a Single Page Application(SPA), whose domain is http://teachme.com. The routes could be seen as

teachApp.config(['$routeProvider', '$locationProvider', function($routeProvider,       $locationProvider) {
        when('/teach/', {templateUrl: 'views/login_view.html'}).
        when('/teach/overview', {templateUrl: 'views/overview_view.html'}).
        when('/teach/users', {templateUrl: 'views/users_view.html'}).
        otherwise({redirectTo: '/teach/'});

Now everytime i click on the tabs, the route changes and I see the different view, but URL changes to


which fails the whole point of keeping the url unique and for bookmark purposes. Is there a way that routes work fine, but the URL stays to http://teachme.com

Muchas Gracias

preguntado el 05 de mayo de 13 a las 20:05

1 Respuestas

The whole point of routes is to use enlace profundo, para los docs.

The domain & path components of your URL will always remain constant, however the component after the # is what changes, which allows bookmarks to work even though you are creating a single page app.

Short version is No, routing will not work if you don't want the portion of the URL after the # to be changed. To me it seems like you loose value for bookmarking in the absence of such additions.

Even on a single page app, you can bookmark the enseñar or visión de conjunto section etc. Maybe you provide a marcador link which always stamps the domain by itself in the bookmark for the user.

contestado el 05 de mayo de 13 a las 20:05

In all fairness, I looked through some of the apps on esta página. The URL never changes, not even after the #. Some of the links are pointing to /#some-section but the URL still doesn't change. They're probably just preventing the default anchor behavior there. I dunno, personally I find the Angular approach more advanced since the back button still works and you can directly link into some particular page/state of the app. - cambios rápidos

Thanks for all your effort, I read through the pages and realized that Angular approach is better - soñador

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.