Angular JS 'route' doesn't match component with / (encoded '/')

前端 未结 4 870
难免孤独
难免孤独 2021-01-07 20:05

I have a \'route\' in Angular JS as follows

$routeProvider.when(\'/foos/:fooId\', { controller: FooController, templateUrl: \'foo.html\'});

4条回答
  •  无人及你
    2021-01-07 20:33

    You need not to encode anything here. Just add * in your path Param as mentioned below and enable html5Mode

     app.config(function ($routeProvider, $locationProvider) {
     $routeProvider
    .when('/home', {templateUrl: 'home.html', controller: 'HomeCtrl'})
    .when('/base/:path*', {templateUrl: 'path.html', controller: 'pathCtrl'})
    .otherwise({redirectTo: '/home'});
    });
    
     $locationProvider.html5Mode({
      enabled: true,
      requireBase: false
     });
    

提交回复
热议问题