5

i have this routing code on my app:

var app = angular.module('docFinder', [])

app.config(function($routeProvider){
    $routeProvider.
      when('/', 
      {            
        controller: docTable,
        templateUrl: 'partials/finder.html'
      }).
      when('bio/:finderId', 
      {          
        controller: bioCtrl,
        templateUrl: 'partials/bio.html'
      }).
      otherwise({redirectTo: '/'});
});

when i start my app and go to root y click on a link to the second route

once i get there i hit the back button on my browser and it dosn't goes back it only refreshes my current page, any ideas on the problem?

EDIT:

Solution

<tr ng-repeat="doc in providers" ng-mouseover="mouseOverDoc(doc)" ng-mouseleave="mouseLeave()">      
   <td><a href="#bio/{{doc.provider.Id}}"> {{doc.provider.FirstName}} </a></td>

</tr>
5
  • Your routes look about right, can you show the code you use to go to another page? Commented Jun 6, 2013 at 16:33
  • This doesn't work with IE7 (at least), if that's what you're using Commented Jun 6, 2013 at 16:43
  • im on chrome, and it dosn't work Commented Jun 6, 2013 at 16:47
  • Wouldn't a path such as "/" matches both your route / and /:finderId (finderId being null). Did you try with a route such as /bio/:finderId, just to make sure AngularJS doesn't get confused with the routes? Commented Jun 6, 2013 at 16:53
  • just tried, and didnt work, i edited my questio with the changes Commented Jun 6, 2013 at 17:09

2 Answers 2

8

Use #/ on link. it seems bug on angular js. for example:

 <td><a href="#/bio/{{doc.provider.Id}}"> {{doc.provider.FirstName}} </a></td>
Sign up to request clarification or add additional context in comments.

Comments

5

It doesn't seem to be a bug to me.

AngularJS provides two configuration modes for $location service to control the format of the URL in the browser's address bar.

  1. Hashbang Mode (#!)
  2. HTML5 Mode

This can be resolved if you set the configuration to HTML5 Mode using { html5Mode: true }.

1 Comment

It seems like it shouldn't correctly handle both in either mode. Non-hash links should fail in hashbang mode, and hash links should fail or only trigger a search change in html5 mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.