2

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>

2 Answers 2

1

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>
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.