$routeProvider is not defined - Unable to get through this

61 Views Asked by At

I've been trying to get a basic project running with ng-route.

I have two views - View A and View B. They are controlled per

flipFlop.config(['$routeProvider', function ($routeProvider) {
    $routeProvider
        .when('/view/a', {
             templateUrl: 'app/viewA.html',
             controller: 'ViewAController'
     })
        .when('/view/b', {
            templateUrl: 'app/viewB.html',
            controller: 'ViewBController'
        })
        .otherwise({
            redirectTo: '/view/a'
        });
}]);

My index.html file looks like

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body ng-app="flipFlop">



<script src="./node_modules/angular/angular.js"></script>
<script src="./node_modules/angular-route/angular-route.js"></script>
<script src="./node_modules/angular-route/angular-route.min.js"></script>
<script src="./app/flipFlop.js"></script>
<script src="./app/ViewAController.js"></script>
<script src="./app/ViewBController.js"></script>

<div ng-view></div>
</body>
</html>

and each of my view files look like

<!DOCTYPE html>
<html lang="en">
<div id = "viewB">View B</div>
</html>

The error log looks like

enter image description here

It looks like a very stupid mistake. Could someone please point it out?

1

There are 1 best solutions below

1
MarkoCen On

You need to initiate the flipFlop module first..

const flipFlop = angular.module('flipFlop', ['ngRoute']);
flipFlop.config([ ... ])