Add ngRoute to angularjs

I am using angularjs with yeoman. I am trying to add ngRoute to my project. I install it using 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 create myApp module due to: [$ injector: modulerr] Failed to create ngRoute module due to: [$ injector: nomod] Module 'ngRoute' is not available! You either misspelled the module name or forgot to load it. If you register the module ensures that you specify the dependencies as the second argument.

+3


source to share


2 answers


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

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



For installation instructions see the ngRoute API .

+4


source


you need to pass angular-route.js, pls find the cdn link like this

<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 cdn for angular in the following link http://cdnjs.com/libraries/angular.js/1.4.0

+4


source







All Articles