AngularJS控制器不是一个函数

AngularJS controller is not a function

本文关键字:一个 函数 控制器 AngularJS      更新时间:2023-09-26

我在应用程序中找不到错误。我收到的错误堆栈是这个:

错误:[ng:areq] 参数"RepoController"不是函数,未定义

这是应用程序的代码.js

(function() {
var app = angular.module('gitHubViewer',["ngRoute"]);
app.config(function($routeProvider) {
    $routeProvider.when("/main", {
        templateUrl: "main.html",
        controller: "MainController"
    })
    .when("/user/:username", {
        templateUrl: "user.html",
        controller: "UserController"
    })
    .when("/repo/:usermane/:reponame", {
        templateUrl: "repo.html",
        controller: "RepoController"
    })
    .otherwise({
        redirectTo:"/main"
    });
});

}());

这是控制器的代码

(function() {

var module = angular.module('gitHubViewer');
var RepoController = function($scope, github, $routeParams) {
    var onRepoDetailsComplete = function(data) {
        $scope.issues = data;
        github.getRepoCotributors($score.username, $scope.reponame).then(onRepoCotributorsComplete,onError);
    };
    var onRepoCotributorsComplete = function(data) {

        $scope.repoContribuors = data;
    };
    var onError = function(reason) {
        $scope.error = reason;
    }
        $scope.username = $routeParams.username;
        $scope.reponame = $routeParams.reponame;
        github.getRepoDetails($score.username, $scope.reponame).then(onRepoDetailsComplete,onError);
};
module.controller('RepoController',["$scope","github","$routeParams",RepoController]);
}());

你能看看吗,因为我真的找不到我犯的错误。

问候

法比奥

"$score.username"从何而来?

 github.getRepoDetails($score.username, $scope.reponame)

我认为您缺少$score的依赖项,或者您只是拼错了$scope。