Uncaught ReferenceError: angular is not defined

0

I'm having problems because I'm studying angled routes and I came across the following errors in the console

Uncaught ReferenceError: angular is not defined
at app.js:1

And also this

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=app&p1=Error%3A%20%5B%24injector%3Anomod%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.8%2F%24injector%2Fnomod%3Fp0%3Dapp%0A%20%20%20%20at%20http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A6%3A416%0A%20%20%20%20at%20http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A24%3A186%0A%20%20%20%20at%20b%20(http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A23%3A251)%0A%20%20%20%20at%20http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A23%3A494%0A%20%20%20%20at%20http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A38%3A117%0A%20%20%20%20at%20n%20(http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A7%3A333)%0A%20%20%20%20at%20g%20(http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A37%3A488)%0A%20%20%20%20at%20eb%20(http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A41%3A249)%0A%20%20%20%20at%20c%20(http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A19%3A463)%0A%20%20%20%20at%20yc%20(http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A20%3A274)
at angular.js:38
at angular.js:4458
at n (angular.js:340)
at g (angular.js:4419)
at eb (angular.js:4344)
at c (angular.js:1676)
at yc (angular.js:1697)
at Zd (angular.js:1591)
at angular.js:29013
at HTMLDocument.b (angular.js:3057)

here's my index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>
</head>
<script type="text/javascript" src="app.js"></script>
<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-route/angular-route.js"></script>

<body ng-app="app">
    <h1>Este e um exemplo de single page</h1>
    <a href="#/">Home</a>
    <a href="#/sobre">Sobre</a>

    <div ng-view></div>

</body>
</html>

and here the app.js

var app = angular.module('app', ['ngRoute']);
app.route(function($routeprovider){
    $routeprovider
        .when("/", {
            templateUrl : "templates/home.html"
        })
        .when("/about", {
            templateUrl : "templates/sobre.html"
        });

});

I've seen the previous posts have not solved anything I'm using angular and angular-route both are 1.6 using NPM for dependencies if Can someone help me thank you.

    
asked by anonymous 02.12.2017 / 07:20

1 answer

1

I recreated this example in plnkr and made some modifications that worked:

1 - use app.config () instead of app.route (),

2 - use $ routeProvider instead of $ routeprovider (note the capital "P")

I used version 1.6 of the angle for this test that you can check in this plunk

    
02.12.2017 / 16:40