Search code examples
javascriptangularjsroutesngroutehashbang

AngularJs ngRoutes not working


I add this link tag <a href="#/pendingJobs"> And in Js wrote this type of when function

.when("/pendingJobs", {
    templateUrl : 'jobsPending.php',
    controller : 'appCtrl'
})

But when i click on link it create a url like that /#%2FpendingJobsdue to this linking problem .when("/pendingJobs" is not working..


Solution

  • Default value of the prefix is changed to to '!'.

    I don't know which angular version you are using.

    But it should work with this changes.Change hashPrefix to ''

    .config(function($locationProvider) {
      $locationProvider.html5Mode(false).hashPrefix('');
    })
    

    More here https://github.com/angular/angular.js/commit/aa077e81129c740041438688dff2e8d20c3d7b52