Javascript 角度设置控制器和路线图

Javascript 角度设置控制器和路线图,javascript,angularjs,angular-routing,Javascript,Angularjs,Angular Routing,配置应用程序时,我使用routeProvider设置控制器和路由参数。以下是我正在使用的代码: app.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/person/:uuid/report', { controller: 'CandidateCtrl' }). when('/person/:uuid/confirm', { controller: 'Co

配置应用程序时,我使用routeProvider设置控制器和路由参数。以下是我正在使用的代码:

app.config(['$routeProvider', function($routeProvider) {
   $routeProvider.
        when('/person/:uuid/report', { controller: 'CandidateCtrl' }).
        when('/person/:uuid/confirm', { controller: 'ConfirmCtrl', }).
        when('/person/add', { controller: 'AddCtrl' })
}]);
但是,控制器设置不正确。此外,当我在页面本身中使用ng控制器设置控制器时,routeParams对象为空。我做错了什么

编辑:

我也尝试过这个,它也没有将控制器与页面关联,也没有设置路由参数

app.config(['$routeProvider', function($routeProvider) {
   $routeProvider.
        when('/person/:uuid/report', { controller: 'CandidateCtrl', template: 'templates/report.html' }).
        when('/person/:uuid/confirm', { controller: 'ConfirmCtrl', template: 'templates/confirm.html'  }).
        when('/person/add', { controller: 'AddCtrl', template: 'templates/add.html'  })
}]);
这是我正在测试的控制器:

appController.controller('CandidateCtrl', ['$routeParams',
        function($routeParams) { 
    console.log($routeParams);
}]);

尝试添加templateUrl

app.config(['$routeProvider', function($routeProvider) {
  $routeProvider.
  when('/person/:uuid/report', {
    templateUrl: 'partials/CandidateCtrl.html', //TODO : replace with the good template
    controller: 'CandidateCtrl'
  }).
  when('/person/:uuid/confirm', {
    templateUrl: 'partials/ConfirmCtrl.html', //TODO : replace with the good template
    controller: 'ConfirmCtrl'
  }).
  when('/person/add', {
    templateUrl: 'partials/AddCtrl.html', //TODO : replace with the good template
    controller: 'AddCtrl'
  }).
  otherwise({
    redirectTo: 'Something' //TODO : replace with the good url
  });
}]);

我通过我的web mvc提供视图。此后,我将其更改为用于布局,并将部分页面保留在资源文件夹中。

设置不正确是什么意思?为什么在配置路由时没有指定templateUrl属性?@tymeJV:我的意思是控制器与页面没有关联-它没有提取任何适当的信息@SatyamKoyani,我已经试过了,问题已经更新。你能做一个小提琴或分享你控制器的片段吗?@cscan你的控制器片段将帮助我们解决你的问题。发布一些控制器代码片段