Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Routing is messed - Wrong links #1387

Open
arimourao opened this issue Jan 15, 2017 · 7 comments
Open

Routing is messed - Wrong links #1387

arimourao opened this issue Jan 15, 2017 · 7 comments

Comments

@arimourao
Copy link

Well, right out of installation, I run yo angular choose angular-route and angular-resource, everything installs fine. I run grunt and it also installs just fine. I then run grunt serve, the web server is started normally but the routing doesn't work.
I click on 'about' and nothing happens, but the controller and the view are there. I get to the index.html and notice that the links are wrong. It is just <li><a ng-href="#/about">About</a></li>. When I click nothing happens. Adding a '!' after the '#' it works just fine.
I'm not the biggest expert in angularjs around, in fact testing this generator for study purposes, so, there is indeed this issue or am I missing something?

@razvanilin
Copy link

The "!" is a recent change in the angular's routing component. Not really sure why they did that, but I noticed that when I upgraded angular on my projects, the routing was all messed up. So my guess is that the yo generator is not updated with the latest angular routing system.

@samir-plusb
Copy link

Look into the following issue: #1380

You just need to replace the links to the following:

<li><a ng-href="#!/about">About</a></li>

the ! is important here...

@armsofter
Copy link

Same problem on my side.
Question:: Why it was changed? and how to remove it from url?

@ageyev
Copy link

ageyev commented Jan 18, 2017

This is because of changes in AngularJS 1.6.0. To restore previous behavior :

app.config(['$locationProvider', function($locationProvider) {

  $locationProvider.hashPrefix('');

}]);

see: http://stackoverflow.com/questions/41211875/angularjs-1-6-0-latest-now-routes-not-working
and https://docs.angularjs.org/guide/migration#commit-aa077e8

@kutec
Copy link
Contributor

kutec commented Jan 21, 2017

#1388

@Marcelovv2
Copy link

I had the same problem, but is easily fix with the ng-href="#!/....

@thijskoek
Copy link

@samir-plusb Thanks man, this works.

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

8 participants