Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 645
  • Last Modified:

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

0
jackjohnson44
Asked:
jackjohnson44
  • 2
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
which browser?
0
 
jackjohnson44Author Commented:
IE, Chrome
0
 
leakim971PluritechnicianCommented:
be sure your ng-view tag is inside your application and controller.

Test page : http://jsfiddle.net/LLAaR/2/
0
 
jackjohnson44Author Commented:
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now