AngularJS - page can not find the controller

3

I'm starting to test applications using AngularJs and Spring Boot.

My problem is this: All scripts are normally imported into the browser, but IF I put the tag "ng-controller=" HeadController "" in any tag on my page, I have an error saying that "HeadController" is not a function.

My HTML code is as follows:

<!DOCTYPE HTML>
<html ng-app lang="pt-br">
    <head>
        <title>{{title}}</title>        
        <meta charset="utf-8"/>
    </head>

    <body ng-controller="HeadController">
        <p>Qual seu nome?</p>
        <input type="text" ng-model="name">
        <p>Olá, <span ng-bind="name"></span></p>

        <script type="text/javascript" src="../scripts/angular.min.js"></script>
        <script type="text/javascript" src="../scripts/angular-route.js"></script>
        <script type="text/javascript" src="../scripts/jquery-2.2.1.min.js"></script>
        <script type="text/javascript" src="../scripts/bootstrap.min.js"></script>
        <script type="text/javascript" src="../scripts/main.js"></script>
        <script type="text/javascript" src="../scripts/controllers/HeadController.js"></script>
    </body>  
</html>

CSS:

<link rel="stylesheet" src="../css/bootstrap-min.css">
<link rel="stylesheet" src="../css/bootstrap-theme-min.css">

My main.js is:

angular.module('mod', ['ngRoute', 'HeadController']);

My HeadController is:

angular.module('mod').controller('HeadController', function($scope, $http) {
    $scope.title = 'titulo';    
});

All scripts are imported correctly on the page. I use Freemarker as a template engine.

The problem I encounter is the following: Error

Would anyone know how to help me with this?

Thank you in advance,

    
asked by anonymous 14.03.2016 / 03:11

1 answer

4

Add ng-app to your html tag: <html ng-app="mod"> , and remove the injection from your controller in your module, leaving your main.js like this: angular.module('mod', ['ngRoute']);

    
14.03.2016 / 04:06