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

2

I'm creating a web application with angular and I can not make the login screen appear in index.html, out that an error message appears in the console.

  

Uncaught Error: [$ injector: modulerr] link $ injector / modulerr? p0 = weset & p1 = 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><scriptsrc="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');
});
    
asked by anonymous 23.02.2017 / 14:23

2 answers

2

You are trying to use $urlRouterProvider without mentioning the service initialization. Change the line

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

for

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

As @OnoSendai said, you are trying to use a service without injecting it into your main module for 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 to your angular.module and add that module, in your case you should add ui.router .

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

    
23.02.2017 / 15:19