Angular.js failed to instantiate the module

1

Well, it's the first time I've been doing anything with Angular.js and I'm getting a bit of a "Bad Login and Passwords" message with it.

I have a method in a .js file that is below:

angular.module('myApp',[])
    .controller('loginController', function($scope){
        $scope.displayLoginError = (url.indexOf("error") >= 0);
    });

Soon in my .jsp I made the import of the Angular and the file with my method:

    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/angular.min.js"></script>

    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/pages/login.js"></script>

Nesta mesma pagina tenho um form de login com a DIV que faz a verificação 

<div ng-app="myApp">
    <div ng-controller="loginController">
        <div  ng-class="{{'': displayLoginError == true, 'none': displayLoginError == false}}">
            <span class="entypo-attention"></span> <strong>Erro!</strong>&nbsp;&nbsp;Login
            ou Senha Incorretos!
        </div>
    </div>
    <form class="form-signin" method="post"
        action="j_spring_security_check">

        <div class="input-group">
            <span class="input-group-addon entypo-user"></span> <input
                name="j_username" id="j_username" type="text" class="form-control"
                placeholder="Usuario">
        </div>
        <br>
        <div class="input-group">
            <span style="padding: 0 14px;" class="input-group-addon entypo-lock"></span>
            <input name="j_password" id="j_password" type="password"
                class="form-control" placeholder="Senha">
        </div>

        <button type="submit"
            class="btn btn-lg btn-fltees btn-primary btn-block">Entrar</button>

        <a href="<c:url value="register"/>"
            class="btn btn-lg btn-fltees btn-primary btn-block">Crie uma nova
            Agência!</a>

    </form>
</div>

Well, I'm using Spring Security. So when my authentication fails a parameter and added in the URL (...? = Error = 403), then my javascript method can take action and display the message in my form.

The problem with such an error message is displayed:

Does anyone know how I can solve?

EDITION

The method that performs URL verification. In the variable url the value comes right.

angular.module('myApp',[])
    .controller('loginController', function($scope, $location){
        var url = "" + $location.$$absUrl;
        $scope.displayLoginError = (url.indexOf("error") >= 0);
    });

This is the section where you will check for authentication error and will display the message informing:

<div ng-controller="loginController">
    <div class="alert alert-danger" ng-class="{'': displayLoginError == true, 'none': displayLoginError == false}">
        <span class="entypo-attention"></span> <strong>Erro!</strong>&nbsp;&nbsp;Login ou Senha Incorretos!
    </div>
</div>

But the logic does not seem to work and does not show more errors in the firebug console

    
asked by anonymous 12.09.2014 / 02:08

1 answer

1

Well, people have solved the problem by editing the .js file where the method is in which to show the login message or not.

login.js

angular.module('myApp',[])
    .controller('loginController', function($scope, $location){
        var url = "" + $location.$$absUrl;
        $scope.displayLoginError = (url.indexOf("error") >= 0);
    });

This is the section where you will check for authentication error and will display the message:

<div ng-controller="loginController">
    <div class="alert alert-danger" ng-show="displayLoginError">
        <span class="entypo-attention"></span> <strong>Erro!</strong>&nbsp;&nbsp;Login ou Senha Incorretos!
    </div>
</div>

Remember that I had to change the tag by adding the parameter ng-app="myApp"

    
16.09.2014 / 01:49