使用$ stateParams获取错误的angular js

时间:2018-01-24 16:54:59

标签: angularjs angular-ui-router angularjs-injector

我的应用正常运行,但当我在控制器中添加$stateParams 时,我收到此错误:

angular.js:14791 Error: [$injector:unpr] Unknown provider: $stateParamsProvider <- $stateParams <- ClienteViniCtrl

来自: app.js

     .when('/clienti/:id_cliente', {
    templateUrl: 'views/cliente-vini.html',
    controller: 'ClienteViniCtrl'
  })

来自: controller.js

  .controller('ClienteViniCtrl', function($scope, $stateParams, Vini){
  Vini.getWines($stateParams.id_cliente).then(function (result) {
      $scope.vini = result;
  })

有什么问题?

1 个答案:

答案 0 :(得分:0)

你在项目中添加了angular-ui-router.js吗?

var myApp = angular.module('myApp', ['ui.router']);