1

I'd like to navigate to the following url through the browser:

http://localhost:9001/jira. 

This only works if I add a hash to the url, like this:

http://localhost:9001/#/jira.

I tried setting the html5Mode to true, but this only removes the hash from the url. It still does not allow me to navigate directly to the url.

Here is my code:

grey.config( function( $stateProvider, $provide, $locationProvider ) {

$locationProvider.html5Mode( true ).requireBase( false );

// Set up the different views
$stateProvider
    .state('index', {
        url: '',
        views: {
            'jira_filters': {
                templateUrl: 'app/partials/jira_filters.html'
            },
            'ciq_filters': {
                templateUrl: 'app/partials/ciq_filters.html'
            },
            'priority': {
                templateUrl: 'app/partials/priority.html'
            },
            'status': {
                templateUrl: 'app/partials/status.html'
            },
            'rca': {
                templateUrl: 'app/partials/rca.html'
            },
        }
    })
    .state('jira', {
        url: '/jira',
        views: {
            'jira_filters': {
                templateUrl: 'app/partials/jira_filters.html'
            },
            'ciq_filters': {
                templateUrl: 'app/partials/ciq_filters.html'
            },
            'priority': {
                templateUrl: 'app/partials/priority.html'
            },
            'status': {
                templateUrl: 'app/partials/status.html'
            },
            'rca': {
                templateUrl: 'app/partials/rca.html'
            },
        }
    });
});
Molly Harper
  • 2,363
  • 3
  • 26
  • 35
  • If html5Mode 'only' removes the hash, aren't the URLs equivalent? Or do you mean you *don't* want angular-ui-router to handle requests to /jira? – mnemosyn Dec 03 '14 at 18:17
  • It creates an equivalent URL, but doesn't allow me to simply type the URL in that way. – Molly Harper Dec 03 '14 at 18:20
  • Ah, I guess you get a response from the server instead? You'll have to configure your server such that it rewrites all requests to the index page, so to speak. Which server are you using? – mnemosyn Dec 03 '14 at 18:44
  • Yep, I get a "Cannot GET /jira" from the server. I am using Express. – Molly Harper Dec 03 '14 at 18:47
  • See http://stackoverflow.com/questions/17777967/using-angularjs-html5mode-with-nodejs-and-express - essentially, you must tell your server to hand off all requests but a few to the index page so the index page with the angular javascript is served to the browser. Then angularjs starts to run and can inspect the URL, thus activating the correct route. – mnemosyn Dec 03 '14 at 18:52

0 Answers0