0

I've got an asp.net MVC application and I'm trying to apply mini-spas

My angular js setp:

appNg.config(function ($routeProvider, $locationProvider) {
$routeProvider
    .when("/AccountManager/UserLogin", {
        templateUrl: "/App_ng/AccountManager/Views/AccountManagerUserLoginView.html",
        controller: "accountManagerUserLoginController",
    })
    .when("/AccountManager/UserSignup", {
        templateUrl: "/App_ng/AccountManager/Views/AccountManagerUserSignupView.html",
        controller: "accountManagerUserSignupController",
    });

$locationProvider.html5Mode(true);

console.log("Config.Complete: appNg");

});

my baseref in _layoutpage in head tag (at the top)

   <base href="/" />

my links on layoutpage:

WORKING:
<a href="/AccountManager/UserSignup"><i class="fa fa-sign-in"></i> <span>ng UserSignup</span></a>
<a href="/AccountManager/UserLogin"><i class="fa fa-sign-in"></i> <span>ng UserLogin</span></a>
<a href="http://cnn.com"><i class="fa fa-sign-in"></i> <span>CNN.COM</span></a>
NOT WORKING:
<a href="/AngTestRoute/about2"><i class="fa fa-sign-in"></i> <span>ng About2</span></a>

The first 3 links work as expected, but the last link does not, the address in the browser url bar changes, but the page stays the same.

I want angular to ignore the route and let me call the server to get a new page, so that I can load the new page with embedded the mini-spa related to the new address. Since the address that is not working is not present in the $routeProvider routes, I was hoping that angular would have not filtered the address. How can I solve the issue?

Yes, I know I can use target _blank on the a tag but this can't be done (from my trials), since this will create issues with links that should be filtered by angular when in a specific mini-spa.

I've also read AngularJS - How can I do a redirect with a full page load? without any success.

Community
  • 1
  • 1
Carlo Luther
  • 2,402
  • 7
  • 46
  • 75

1 Answers1

0

This one bites me pretty frequently. We use ui-router, but I think ngRoute is the same. Try target="_self" in your anchor tag.

<a target="_"self" href="/AngTestRoute/about2"><i class="fa fa-sign-in"></i> <span>ng About2</span></a>

Glancing at some of my own projects, I think I also use the fully qualified url, and not just the path. So maybe

<a target="_"self" href="http://myserver/mybasepath/AngTestRoute/about2"><i class="fa fa-sign-in"></i> <span>ng About2</span></a>
n daniel
  • 148
  • 1
  • 10