Shashank Vivek
Shashank Vivek

Reputation: 17494

Failing to instantiate ngRoute for a View

I am using below piece of code in my JS file:

var mainAngular = angular.module('baniyaApp', ['ngRoute','ui.bootstrap']);

////======================== CONFIG =================================
mainAngular.config(function($routeProvider, $locationProvider) {
alert('ng route');
$routeProvider
        .when('/', {
            templateUrl: "HomeLandPage.html"
        });
});
////=================================================================

"HomeLandPage.html" exists at the same location, so no issue with the path. The main page that contains ng-view in it.I have taken care of using angular.js file from http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.js link.

I am getting the below error on the console. Please confirm that the JavaScript file is correct.

Uncaught Error: [$injector:modulerr] Failed to instantiate module baniyaApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
Error: [$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.

Upvotes: 1

Views: 59

Answers (1)

Felipe Skinner
Felipe Skinner

Reputation: 16616

You need to include angular-routes.js after including angular.js in your app directory and html

Upvotes: 2

Related Questions