似乎无法将 angular-jwt 注入工厂

Can't seem to inject angular-jwt into factory

我正在尝试将 angular-jwt 注入工厂以用于 auth 函数,但我一直收到错误

`错误:[ng:areq] 参数 'fn' 不是函数,得到了字符串 http://errors.angularjs.org/1.3.15/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20string

return new ErrorConstructor(消息);`

代码如下: webapp.factory('Auth', ['angular-jwt'], function($http, API_URL, $window, $location, jwtHelper ) {

angular 的学习曲线在这方面看起来很陡峭,我应该如何理解错误以找出它失败的原因?谢谢!

在您的应用模块中注入所有必需的依赖项。那就是您在声明工厂时注入新模块的内容。

代码

var webapp = angular.module('myAppName',['angular-jwt']);

webapp.factory('Auth',['$http', 'API_URL', '$window', '$location', 'jwtHelper', 
   function($http, API_URL, $window, $location, jwtHelper ) {
   //your c0de here
}]);