generator-angular icon indicating copy to clipboard operation
generator-angular copied to clipboard

Routing is messed - Wrong links

Open arimourao opened this issue 8 years ago • 7 comments

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?

arimourao avatar Jan 15 '17 11:01 arimourao

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.

razvanilin avatar Jan 16 '17 10:01 razvanilin

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...

samir-plusb avatar Jan 16 '17 12:01 samir-plusb

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

armsofter avatar Jan 18 '17 18:01 armsofter

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

ageyev avatar Jan 18 '17 19:01 ageyev

https://github.com/yeoman/generator-angular/pull/1388

kutec avatar Jan 21 '17 16:01 kutec

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

Marcelovv2 avatar May 02 '17 20:05 Marcelovv2

@samir-plusb Thanks man, this works.

thijskoek avatar Jun 16 '17 19:06 thijskoek