Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

rc11 seems to have added extra encoding to links #1037

Closed
andyneville opened this issue Jun 11, 2012 · 11 comments
Closed

rc11 seems to have added extra encoding to links #1037

andyneville opened this issue Jun 11, 2012 · 11 comments

Comments

@andyneville
Copy link

I apologize for not including a jsFiddle, I couldn't figure out how to get a routing example working there!

In my module config I also add routing like (CoffeeScript):

    ($routeProvider) ->
      $routeProvider.when '/products/:id',
        template: 'partials/product.html'
        controller: @App.Controllers.ProductDetail

        ...

      $routeProvider.otherwise
        redirectTo: '/dashboard'

In my HTML (inside an ng-repeat) I have links similar to this:

    <a href="/#/products/{{product.id}}">{{product.title}}</a>

Until today clicking the link would navigate to /#/products/123 (for example), and properly route to that controller.

However, this morning I upgraded to rc11, and followed the upgrade steps (e.g., change template to templateUrl), and now when I click the link it navigates to /#/dashboard#%2Fproducts%2F123

I'm not sure if there's extra encoding being added now in rc11, or if the $routeProvider.otherwise functionality has changed, but as far as I can tell I'm using routing the way the tutorial says, and now it's not working w/ rc11.

@andyneville
Copy link
Author

I found a similar issue discussed in Google Groups at https://groups.google.com/d/msg/angular/p6TkKUmXOhA/_LJ8Rf2Q71wJ

@IgorMinar
Copy link
Contributor

Your link seems to be incorrect.

Instead of :

 <a href="/#/products/{{product.id}}">{{product.title}}</a>

It should be:

 <a href="#/products/{{product.id}}">{{product.title}}</a>

Does that resolve the problem?

(PS: if you are using hash(bang) urls then your links must start with # and not /#, this is how HTML works and is not in any way related to Angular)

@andyneville
Copy link
Author

Thanks for the pointer about the leading slash being incorrect, that's good to know!

However, I can confirm that removing the leading slash does not resolve the issue, the link <a href="#/products/{{product.id}}">{{product.title}}</a> still takes me to /#/dashboard#%2Fproducts%2F123

@ProLoser
Copy link
Contributor

Use ng:href instead of href

@andyneville
Copy link
Author

Thanks for the suggestion. I just changed to ng-href instead of href, and still see the same problem. And as someone pointed out in the Google Groups thread (https://groups.google.com/d/msg/angular/-/bdJwu5Jd_MwJ), this problem also occurs in angular-seed for rc11 (click the View 1/View 2).

@IgorMinar
Copy link
Contributor

ngHref is not going to fix this. This is a regression. I was able to
reproduce it with angular-seed.

We'll issue a fix today.

/i

On Mon, Jun 11, 2012 at 1:59 PM, andyn3 <
reply@reply.github.com

wrote:

Thanks for the suggestion. I just changed to ng-href instead of href, and
still see the same problem. And as someone pointed out in the Google
Groups thread (https://groups.google.com/d/msg/angular/-/bdJwu5Jd_MwJ),
this problem also occurs in angular-seed for rc11 (click the View 1/View 2).


Reply to this email directly or view it on GitHub:
#1037 (comment)

@onpulse
Copy link

onpulse commented Jun 11, 2012

Thanks Igor! Can't wait to sink my teeth into Angular

@kylefinley
Copy link

Maybe I'm doing something wrong, but this still isn't working for me with hashbang urls. In Angular-seed I made these changes.

app.js

angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives']).
  config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    $routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: MyCtrl1});
    $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: MyCtrl2});
    //$routeProvider.otherwise({redirectTo: '/view1'});
    $locationProvider.hashPrefix('!');
  }]);

index.html

  <ul class="menu">
    <li><a href="#!/view1">view1</a></li>
    <li><a href="#!/view2">view2</a></li>
  </ul>

Clicking view2 changes the url to:

_http://localhost:8000/app/index.html#!/!/view2_

Is the ! not to be used in the html?

Thank you,

Kyle

@IgorMinar
Copy link
Contributor

we are looking into this

@IgorMinar
Copy link
Contributor

can you please verify that this build works well for you: http://ci.angularjs.org/job/angular.js-misko/594/artifact/build/pkg/1.0.0rc12/

@kylefinley
Copy link

@IgorMinar

Yes it's working now. Thank you!

IgorMinar pushed a commit to IgorMinar/angular.js that referenced this issue Jun 13, 2012
This is a second fix for a regression that was introduced by 92a2e18.
The fix addresses scenarios when the $location service is configured with
a hash prefix.

Closes angular#1037
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants