Add ngRoute to angularjs

user567 picture user567 · Jun 17, 2015 · Viewed 21.5k times · Source

I am using angularjs with yeoman. I am trying to add ngRoute to my project. I've install it with bower

"angular-route": "~1.4.1",

and when I try to load it in app.js I get this error

angular.module('myApp', ['ngAnimate', 'ngCookies', 'ngResource', 'ui.router', 'ngSanitize', 'ngTouch','ngRoute'])

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

Answer

Balaji Marimuthu picture Balaji Marimuthu · Jun 17, 2015

you need to refer the angular-route.js, pls find the cdn link as follows

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular-route.min.js"></script>

also you can get the latest version cdn for angular in following link http://cdnjs.com/libraries/angular.js/1.4.0