1
I am having trouble loading my application in the browser. The url works but the screen does not show any content, does not show the view html.
Follow the index.html:
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PierX - WebAdmin</title>
<link rel="stylesheet" type="text/css" href="css/login.css">
<link rel="stylesheet" type="text/css" href="css/dados.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>
</head>
<body ng-app="pierx">
<style>
body {
background: #AAB7B8;
}
</style>
<div ng-view></div>
<script src="js/controllers/login.js"></script>
<script src="js/rotas.js"></script>
</body>
</html>
Follow the view I want to load in the browser:
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="box">
<h3>TELA DE LOGINgfsdggsgsgdss</h3>
<hr>
<div class="input-group" ng-app="pierx" ng-controller="loginCtrl">
<input type="text" class="form-control" placeholder="Cnpj" ng-model="users.cnpj">
<input type="text" class="form-control" placeholder="Email" ng-model="users.email">
<input type="text" class="form-control" placeholder="Senha" ng-model="users.senha">
</div>
</div><br>
<div class="text-center">
<a href="#/dados.html"><button type="button" class="btn btn-success left">Entrar <span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button></a>
<button type="button" class="btn btn-danger right">Sair <span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
</div>
</div>
</div>
Follow the controller:
var app = angular.module('pierx', ['ngRoute', '$scope', '$location']);
app.controller('loginCtrl', function($scope, $location){
$scope.texto = "Tkjfsaiojfiojfaijas";
$scope.users = [
{cnpj:"", email:"", senha:""},
];
});
Follow the route:
var app = angular.module('pierx', ['ngRoute']);
app.config(function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true); // remove o # da url, padrão
$routeProvider
.when('/', {
templateUrl : '/views/login.html',
controller: 'controller/login.js'
})
.when('/dados', {
templateUrl : '/views/dados.html',
controller: 'controller/dados.js'
})
.otherwise ({ redirectTo: '/' }); // caso não seja nenhum desses, redirecione para a rota '/'
});
in the browser is shown some error?
– Lennon S. Bueno
Shows no message no.
– LeAndrade
@Leandro open the tools (F12 normally) of your browser and see what error appears in the console.
– Omni
without html5Mode works? otherwise it is necessary to configure it
– Felipe Duarte
@Leandro also, it seems that the error is in the fact that it is declaring the same module
pierx
twice, once before thecontroller
, again before theconfig
– Omni
It doesn’t work not even taking away html5Mode
– LeAndrade
console error of a this: angular.js:88 Uncaught Error: [$Location:nobase] http://errors.angularjs.org/1.6.5/$Location/nobase at angular.js:88 at Mf.$get (angular.js:14297) at Object.invoke (angular.js:5040) at angular.js:4832 at d d (angular.js:4981) at e (angular.js:5006) at Object.invoke (angular.js:5032) at angular.js:4832 at Object. d [as get] (angular.js:4981) at instantiateRoute (angular-route.js:899)
– LeAndrade
then it is html5Mode error, ie if taking it out does not work you possibly have 2 errors, I will reply one then say which error appears
– Felipe Duarte
Guys got here was missing the base tag in the head of the index.html.
– LeAndrade