What is this error that appears on the console, rotating angular?

Asked

Viewed 277 times

2

I’m creating an angled web application and can’t make the login screen appear in index.html, out of which an error message appears in the console.

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.2/$injector/modulerr? P0=weset&p 1=Error%3A%2... oogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.6.2%2Fangular.min.js%3A45%3A20)

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>

<script src="js/app.js"></script>
<script src="js/wesetConfig.js"></script>

<script src="controllers/loginCtrl.js"></script>

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

</head>
<body>

    <div ng-view></div>

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

app js.

var app = angular.module('weset', []);

controller js.

app.controller('loginCtrl', ['$scope', '$http',function($scope, $http){

}])

config.js

app.config(function($stateProvider, $urlRouterProvider) {

$stateProvider

.state('login', {
  url: '/login',
  templateUrl: 'templates/login.html',
  controller: 'loginCtrl'
});

$urlRouterProvider.otherwise('/login');
});

2 answers

2


You’re trying to use $urlRouterProvider without the service startup mention. Change the line

var app = angular.module('weset', []);

for

var app = angular.module('weset', ['ui.router']); // Adiciona ui-router ao 
                                                  // ciclo de inicalização

2

As @Onosendai said, you are trying to use a service without injecting it into your main module of your Angularjs application.

Whenever you want to use a service that is not "native" to Angularjs, you need to import the file into your index.html, then go on your angular.module and add this module, in your case you should add the ui.router.

When you add it into your angular module, it will create the reference to the service you are trying to call, which is the $urlRouterProvider

Browser other questions tagged

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