How to get out of an Angularjs SPA (Single Page Application)

Asked

Viewed 161 times

0

I have following code:

var app = angular.module("appSystem", ['ngRoute']);

app.config(function ($routeProvider, $locationProvider) {
    $routeProvider
    .when("/teste", {templateUrl: './view/teste.html', controller: 'testeController'})
    .when("/about", {templateUrl: './view/sobre.html', controller: 'sobreController'})
    .otherwise({redirectTo: "/app"});

    $locationProvider.html5Mode(true);
});

Let us imagine the following situation

The site has static pages and has links in its navigation bar to them, suppose we have Home, Login and Register, beyond these static pages we have a, call Applying, where is a spa that I use the Angular.

  • These two pages that are in the configuration of the app are my views hypothetical.
  • The base url for the SPA defined in html is <base href="/aplicacao" />

The rest is all running and does not come to the case here.

How I get out of the spa?

That is, since I had my navigation bar that made requests to the server to change pages, with this configuration of routes everything changes.
How do I set within the Angular that the routes established for the links in the navigation bar (and also in some footer) are met outside the SPA?

  • 1

    One output would be to implement iframes. Another, Use <a href='[link]' target="_Blank">`.

  • You are using the Html5 route mode, $locationProvider.html5Mode(true)? https://docs.angularjs.org/guide/$Location

1 answer

2


At the SPA, you can put a button to exit or in some function return to some home url, you can use the window.location.assign("http://exemplo.com.br/home"); javascript.

  • Dude, this way works too but I ended up using the form commented by @Onosendai!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.