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

url contain '%2F' instead of '/' #1380

Closed
barbhackk opened this issue Dec 12, 2016 · 11 comments · Fixed by mikela/generator-angular#1 or #1381
Closed

url contain '%2F' instead of '/' #1380

barbhackk opened this issue Dec 12, 2016 · 11 comments · Fixed by mikela/generator-angular#1 or #1381

Comments

@barbhackk
Copy link

Hi,

I started a new project using the generator Yeoman for Angular.
When I used the command 'grunt serve' the webb app starting.
When I click on the navigation (about...), I notice that the corrective page does not load and the URL contain '%2F' instead '/'. So my routing does not work.

Is it an Angular or Generator (Yo) problem? Do you have an idea ?

I'm on Macbook Pro, OS El Capitan.

Thx,

Sébastien (PNT)

@blakoD-zz
Copy link

blakoD-zz commented Dec 12, 2016

Which angular version is using? if you fetch the latest Angular JS 1.6.0 version, you should downgrade angular version to 1.5.8.
See #1379 .

@barbhackk
Copy link
Author

I try this solution. Thanks a lot.

Sébastien

@barbhackk
Copy link
Author

Hi,

Finally I did not need to downgrade Angular. I'm running on Angular 1.6.0.
It is enough to replace the links href="#/blog" by "#!/blog" and it works for me.

Can customize it thanks to the method $locationProvider : https://docs.angularjs.org/api/ng/provider/$locationProvider

$locationProvider.hashPrefix(''); The default value for the prefix is '!', so #!/url

Thanks,

Sébastien

@reshadf
Copy link

reshadf commented Dec 13, 2016

I had the same issue which caused problems for hours yesterday. Where did you place this location provider? And are you using #!/about now or without !

@barbhackk
Copy link
Author

barbhackk commented Dec 13, 2016

Hi,

Now, use #!/ link instead #/ link. Work fine for me.
If you want to use only #/ link, place this code $locationProvider.hashPrefix(''); like this :

angular
  .module('webApp', ['ngAnimate', 'ngAria', 'ngCookies', 'ngMessages', 'ngResource', 'ngRoute', 'ngSanitize', 'ngTouch'])
  .config(function ($routeProvider, $locationProvider) {
    $routeProvider
      .when('/blog', {
        templateUrl: 'views/blog.html',
        controller: 'BlogCtrl',
        controllerAs: 'blog'
      })
      .otherwise({
        redirectTo: '/'
      });

     $locationProvider.hashPrefix('');
  });

Sébastien

@cheenbabes
Copy link

^^ This solution is the simplest and works perfectly. Thanks

@mikela
Copy link
Contributor

mikela commented Dec 18, 2016

Hmmm, I tried to send a PR to fix this as suggested by Playntek but somehow it didn't work as expected. Advice welcome 🤔

@destpat
Copy link

destpat commented Mar 14, 2017

Look Developer Guide, Migrating from 1.5 to 1.6 for more information https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6

@ashu17188
Copy link

I resolved by
1.Upgrading Angularjs version to 1.5.8 .
2.By adding $locationProvider.hashPrefix(''); in app.js file.

@suyash0103
Copy link

Thanks a lot @sebast1. I had wasted an hour for this problem, checking my code. Thanks a lot!

@lacherv
Copy link

lacherv commented Feb 27, 2018

Thank you @sebast1. You are a saviour.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
9 participants