Link to home
Start Free TrialLog in
Avatar of jackjohnson44
jackjohnson44

asked on

angular my links keep posting back if I try to use html 5 mode

I can get my angular routing working using /#/page without posting back.  When I change to html5Mode, I can successfully remove the "/#" and show the right controller, but the page keeps posting back.  It is an asp.net mvc application, but I don't think that matters.  The link I click on is all html, so there should be no asp.net interaction.  

I am looking to get rid of the hashmark in the link.


My link which works but causes a post back
<a href="/angular/grid">Grid</a>

Link works without a postback in non-html5mode
<a href="/#/angular/grid">Grid</a>


My app.js file.  This is the version without the /#, If I were to add it to the links and remove the html5mode line, it works, but with the hashes.

'use strict';
var jTradeApp = angular.module('jTradeApp', ['ngTable']);

jTradeApp.config(function($locationProvider, $routeProvider) {
    $locationProvider.html5Mode(true);
    $routeProvider
        .when('/angular/grid', {
            templateUrl: '/templatesangular/PositionsGrid.html',
            controller: 'TradeGridController'
        })
        .when('/angular/error', {
            templateUrl: '/templatesangular/Error.html',
            controller: ''
        }).otherwise({ redirectTo: '/angular/grid' });
});

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

which browser?
Avatar of jackjohnson44
jackjohnson44

ASKER

IE, Chrome
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help.  My actual issue was a surrounding div with a class "sidebar-nav".  I have a boilerplate starter css page which I was using.  I changed the class and everything started working.  I used your links and found that when they were at the bottom of the page my app worked, when they were in the div, they didn't work.