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">Gri d</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.
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<
Link works without a postback in non-html5mode
<a href="/#/angular/grid">Gri
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' });
});
which browser?
ASKER
IE, Chrome
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.