Add ngRoute to angularjs

22k views Asked by At

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.

2

There are 2 answers

0
Jaanus Varus On BEST ANSWER

Make sure that in addition to including angular.js you also include:

<script type="text/javascript" src="path/to/angular-route.js"></script>

See ngRoute API for installation instructions.

0
Balaji Marimuthu On

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