generator-angular
generator-angular copied to clipboard
Routing is messed - Wrong links
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?
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.
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...
Same problem on my side. Question:: Why it was changed? and how to remove it from url?
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
https://github.com/yeoman/generator-angular/pull/1388
I had the same problem, but is easily fix with the ng-href="#!/....
@samir-plusb Thanks man, this works.