angelo
angelo

Reputation: 37

First AngularJS + Angular UI Router

Hi guys can you help me I'm just starting to learn angularjs. How to deal with these errors

  1. app.js:6 > Uncaught ReferenceError: angular is not defined
  2. angular.min.js:6 > Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.20/$injector/modulerr?p0=ajs&p1=Error%3A%20…%2F%2FC%3A%2FUsers%2FABK3%2FDesktop%2Fajs%2Fjs%2Fangular.min.js%3A18%3A139)

Thanks in advance guys

var app = angular.module('ajs', ['ui.router'])

<!DOCTYPE html>
<html ng-app="ajs">
<head>
    <meta charset="utf-8">
    <title>AJS</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
    <h1 ui-view>Hi</h1>
</body>

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

<script src="js/angular.min.js"></script>
<script src="js/angular-ui-router.min.js"></script>
<script src="jquery/jquery.min.js"></script>

</html>

Upvotes: 2

Views: 54

Answers (2)

MaieonBrix
MaieonBrix

Reputation: 1624

You must put all of your script tags that calls angular BEFORE your app.js because your app.js needs angular.

Because here your file loads app.js then angular

Upvotes: 0

Lucio
Lucio

Reputation: 5408

Make sure your scripts are loaded after angular so they can actually do something. The load order is important, for instance make sure to load jQuery before anything, almost all the libraries requires them to be previously loaded.

<!-- Load vendors -->
<script src="jquery/jquery.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/angular-ui-router.min.js"></script>

<!-- Load source code -->
<script src="app.js"></script>

Upvotes: 1

Related Questions