0

Boa noite, galera! Sou iniciante em Angularjs, estou tendo o seguinte problema

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

e aqui está o código.

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!!";

        });
1
  • Boa! O mesmo erro aconteceu comigo e o problema era que o arquivo js do controller não estava no index.html. Obrigado. Commented 21/01/2020 às 20:31

1 Resposta 1

2

Você deve incluir seus arquivos de controller depois da definição do app, não antes.

<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>

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .