AngularJS Argument 'controller' is not a function, got undefined

0

Good evening, guys! I am a beginner in Angularjs, I am having the following problem

Error: [ng:areq] Argument 'smgoCtrl' is not a function, got undefined
http://errors.angularjs.org/1.5.5/ng/areq?p0=smgoCtrl&p1=not%20a%20function%2C%20got%20undefined
minErr/<@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:68:12
assertArg@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:1880:1
assertArgFn@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:1890:1
$controller@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:10091:9
setupControllers@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:9209:34
nodeLinkFn@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:9002:32
compositeLinkFn@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:8397:13
compositeLinkFn@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:8400:13
publicLinkFn@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:8277:30
bootstrapApply/<@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:1751:11
$RootScopeProvider/this.$get</Scope.prototype.$eval@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:17229:16
$RootScopeProvider/this.$get</Scope.prototype.$apply@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:17329:20
bootstrapApply@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:1749:9
invoke@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:4665:16
bootstrap/doBootstrap@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:1747:1
bootstrap@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:1767:1
angularInit@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:1652:5
@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:30863:5
trigger@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:3166:7
defaultHandlerWrapper@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:3456:3
createEventHandler/eventHandler@file:///C:/Users/Alair/Desktop/showmustgoon/lib/angular/angular.js:3444:9
" a

and here's the code.

Index.html
<html ng-app="smgo">
<head>
    <meta charset="UTF-8">
    <title>Titulo</title>
    <link rel="stylesheet" type="text/css" href="lib/bootstrap/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/app.css">
    <script src="lib/angular/angular.js"></script>
    <script src="js/controller/smgoCtrl.js"></script>
    <script src="lib/angular/angular-messages.js"></script>
    <script src="js/app.js"></script>
    <script src="lib/angular/angular-locale_pt-br.js"></script>


</head>
<body ng-controller="smgoCtrl">
    <div class="jumbotron">
    {{message}}
    </div>
    <div ng-include="'view/footer.html'"></div>
</body>
</html>

app.js
angular.module("smgo", []);

controller.js
angular.module("smgo").controller("smgoCtrl", function($scope){
            $scope.message = "Hello!!";

        });
    
asked by anonymous 24.04.2016 / 02:46

1 answer

2

You should include your controller files after the app definition, not before.

<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-locale_pt-br.js"></script>
<script src="lib/angular/angular-messages.js"></script>

<script src="js/app.js"></script>
<script src="js/controller/smgoCtrl.js"></script>
    
24.04.2016 / 18:08