2016-09-23 31 views
0

这行代码并没有让我睡觉:为什么我的角度厂掷类型错误:__tracer.traceFunCall(...)不是一个函数

$scope.search = function (login) { 
     github.getUser(login).then(onUserResponse, onError); 
    }; 

加载起来:

angular.module('lol') 
    .factory('github', github); 

返回两个功能:

return { 
     getUser: getUser, 
     getRepos: getRepos 
    }; 

有了这个siganture:

var github = function ($http) { 

消耗的MainController:

var MainCtrl = function ($scope, github, $filter, $timeout, $intervel, $anchorScroll, $location) { 

而没有注入它的依赖:

MainCtrl.$inject = ['$scope', '$filter', '$interval', '$timeout', '$anchorScroll', '$location']; 

随着应用程序加载这样的:

angular.module('lol', []) 
    .controller('MainCtrl', MainCtrl); 

而这一切抛:TypeError: __tracer.traceFunCall(...) is not a function

+0

[jsbin(http://jsbin.com/mifukibugu/edit?html,js,console,output) –

回答

0

我想你错过了github作为第二个参数在MainCtrl.$inject = ['$scope', 'github'... 也更新了你的jsbin here 代码组织更复杂的情况比需要更多。从外观上来看 你也尝试做两个模块简单的例子应该如何做here.

+0

然后我得到一个错误'错误:[$注入器:unpr]未知的提供者:v0Provider < - v0 < - github' –

+0

只需将你的代码m8粘贴到jsbin或plunker中并共享链接,现在它太多了。从错误的角度看,找不到'github'工厂。 – Augustas

+0

https://jsbin.com/mifukibugu/edit?html,js,console,output –

相关问题