$stateParams传值 undefined原因

来源:互联网 发布:网络推广信息方案 编辑:程序博客网 时间:2024/05/19 03:22



down voteaccepted

比如下面代码,导致传值会是undefined 

angular.module('myApp').controller('CategoriesCtrl',    ['$scope', '$http', '$stateParams',    function($scope, $stateParams, $http){

因为上边依赖注入时的顺序没有一一对应,纠正如下即可

angular.module('myApp').controller('CategoriesCtrl',    ['$scope', '$http', '$stateParams',    function($scope, $http, $stateParams){

4down voteaccepted

The order of your injected services is in correct, change this line

angular.module('myApp').controller('CategoriesCtrl',    ['$scope', '$http', '$stateParams',    function($scope, $stateParams, $http){

to be

angular.module('myApp').controller('CategoriesCtrl',    ['$scope', '$http', '$stateParams',    function($scope, $http, $stateParams){

原创粉丝点击