7

I have linked the script in my index.html, and referenced it in app.js, but I keep getting the error that ngRoute is not available. Any help would be greatly appreciated!

app.js

angular.module('gameMaster', ['ngRoute', 'castServices']);

.config

angular.module('gameMaster')    
    .config(function($routeProvider, $locationProvider){
    $routeProvider
        //welcome page
        .when('/welcome', {
            templateUrl: '../../../../pages/welcome.html',
            controller: 'gameController'
        })

        //gameplay page
        .when('/gameplay',{
            templateUrl: '../../../../pages/gameplay.html',
            controller: 'gameController'
        })

        //default to welcome
        .otherwise({
            redirectTo: '/welcome'
        });
    $locationProvider.html5mode(true);
});

index.html

<html>
<head>
  <title>Party Things!</title>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-route.js"></script>
  <script type="text/javascript" src="https://www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
  <script type="text/javascript" src="node_modules/underscore/underscore.js"></script>
  <script type="text/javascript" src="js/modules/castServices/castServices.js"></script> 
  <script type="text/javascript" src="js/modules/gameMaster/app.js"></script>
</head>

Does anything jump out at you?

Thanks!

AJ Larson
  • 81
  • 1
  • 1
  • 5
  • 1
    Are there any other errors on the page (e.g. one of the files doesn't load properly)? – Jonathan Bender Jun 08 '15 at 21:58
  • 1
    It seems OK. Could you try to reproduce it on live environment / JSFiddle and give us a link? – SzybkiSasza Jun 08 '15 at 22:07
  • As per the [answer](http://stackoverflow.com/a/28761037/2451726), can you replace script type is `javascript` and not `text/javascript` – Arulkumar Jun 09 '15 at 04:50
  • I changed text/javascript to just javascript with no difference. As far as the errors I get, this is all that pops on the page: `Error: [$injector:modulerr] Failed to instantiate module gameMaster due to: [$injector:modulerr] Failed to instantiate module ngRoute due to: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.` – AJ Larson Jun 09 '15 at 13:52
  • 1
    There are lots of other files that load in for the app, or I'd stick it up on fiddle or something -- I edited my answer to include the .config... If I drop the .config and the 'ngRoute' dependency, everything works great. – AJ Larson Jun 09 '15 at 13:56

2 Answers2

21

Just for the record. Now Angular distributes ngRoute module as a separate file - http://docs.angularjs.org/api/ngRoute

You need to download angular-route.js and include in your webpage:

<script src="angular.js">
<script src="angular-route.js">
Tamara
  • 2,910
  • 6
  • 44
  • 73
  • I got the question error while bootstrapping AngularJS inside Angular. So this answer gave me the tip to solve my problem with `$ npm install angular-route`. – MarAvFe Jul 23 '18 at 18:18
1

It turns out that I had caching issues. I went into the developer options and disabled cache while the pane was open, and viola. Thanks for your help!

AJ Larson
  • 81
  • 1
  • 1
  • 5