0

我正在使用Angular JS 1.3,我有ngRoute的问题,在下面的代码中 角度重定向到"apex/" + pathTemplate + "_product"(该页面在Salesforce容器中工作),但控制不返回到控制器homeControllerAngular JS控制器不能使用路由

.when(pathComm + ':categoryCode/:productCode', { 
     templateUrl: function() { 
      return "apex/" + pathTemplate + "_product" 
     }, 
     controller: "homeController" 
    }) 

而是用代码片段以下时的路径只有一个路径变量,它的工作原理:

.when(pathComm + ':productCode', { 
     templateUrl: function() { 
      return "apex/" + pathTemplate + "_product" 
     }, 
     controller: "homeController" 
    }) 
+0

路由代码看起来还好。只需检查是否将控制器添加到应用程序模块: 'OrdersController。$ inject = ['$ scope','$ routeParams'];' 'angular.module('yourApp') .controller('yourController',yourController) ;' – StepUp

+0

控制器刚添加到应用程序模块。 –

回答

0

在HTML中,你必须用URL传递参数参数是这样的:

<a class="btn btn-primary" ng-href="#/student/{{row._id}}/studentName/{{studentName}}">Edit</a>

之后,双第二控制器与URL包含parameters.Like:

.when('/student/:id/studentName/:surName', {        
    templateUrl: 'templates/student/addForm.html', 
    controller: 'YourController' 
}); 

,赶上参数控制这样的:

$http.get('/student/'+$routeParams.id +'/studentName/'+ $routeParams.surName).success(function (response) { 
alert(response); 
$scope.studentList = response; 
$scope.id = response['_id'];});