简体   繁体   中英

AngularJS controller is not a function

I can't find the mistake in my application. The error stack that i receive is this one:

Error: [ng:areq] Argument 'RepoController' is not a function, got undefined

Here is the code of app.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"
    });

});



}());

here is the code of the controller

(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]);

}());

Can you please have a look becuase I really can't find teh mistake that I made.

Regards

Fabio

Where does " $score.username " come from?

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

I think that you are missing a dependency for the $score or you have just misspelled $scope.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM