Angularjs is not working

Asked

Viewed 546 times

1

Why is it that sometimes when we call the angle, it doesn’t work? Check out my HTML

<!DOCTYPE html>
<html ng-app='weset'>
<head>
<title>WESET</title>
<meta charset="utf-8">

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.min.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

</head>
<body>
    <div class="container">
        <div class="row login">
            <div class="col-md-4"></div>
            <div class="col-md-4">{{3+4}}
            <form name="formLogin">
                <label>Email</label>
                <input class="form-control" type="text" name="email" ng-mmodel="usuario.email">
                <label>Senha</label>
                <input class="form-control" type="password" name="senha" ng-mmodel="usuario.senha">
                <a class="btn btn-primary" ng-disabled="formLogin.$invalid" ng-click="logar(usuario)">Logar</a>
            </form>
            </div>
            <div class="col-md-4"></div>
        </div>
    </div>

    <script src="js/jquery-3.1.1.min.js"></script>
</body>
</html>

That {{3+4}} should appear as 7, when I turn the page, but that doesn’t happen, so I know that the angle is not working.

  • What else should I do @jbueno? !

  • What modules are you talking about @Murilogambôa? the app.js?

1 answer

7


Any and all Angular application, needs the directive ng-app to work, in it you reference the module created by you to represent the application.

Since Angularjs does not define a method for the start application. It is the creation of the module that defines how your application will be initialized, what dependencies of it, etc.

I also don’t see any controller in the example that was given.

Here’s an example of your functional code.

angular.module('myApp', []);

angular.module('myApp').controller('mainController', mainControllerFn);

function mainControllerFn(){

}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div class="container" ng-app="myApp">
  <div class="row login" ng-controller="mainController">
      <div class="col-md-4"></div>
      <div class="col-md-4">{{3+4}}
      <form name="formLogin">
          <label>Email</label>
          <input class="form-control" type="text" name="email" ng-mmodel="usuario.email">
          <label>Senha</label>
          <input class="form-control" type="password" name="senha" ng-mmodel="usuario.senha">
          <a class="btn btn-primary" ng-disabled="formLogin.$invalid" ng-click="logar(usuario)">Logar</a>
      </form>
      </div>
      <div class="col-md-4"></div>
  </div>
</div>

  • Has a ng-app in his html tag. That would be it?

  • I saw it, but that’s not the problem. The directive ng-app must be referencing a valid module.

  • Worse, I forgot I had to create the module. valeu @jbueno

Browser other questions tagged

You are not signed in. Login or sign up in order to post.