Search code examples
javascriptangularjscordovaionic-frameworkngcordova

ngCordova [$injector:modulerr] error with Ionic


I'm trying to use ngCordova in my project. I've used bower and installed it, put the full lib/ngCordova/dist/ng-cordova-js path after my Ionic Bundle and before Cordova in my index.html and here is my module:

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngCordova'])

But this error appears:

Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:

Error: [$injector:modulerr] Failed to instantiate module ngCordova due to: ......

I've put everything in the right place, updated everything, but this error keeps appearing, how can i solve it?


Solution

  • That error occurs when you do not correctly load the javascript. Try referencing the ngCordova lib in your index

    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/angular-animate/angular-animate.js"></script>
    <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
    <script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
    <script src="bower_components/ionic/release/js/ionic.js"></script>
    <script src="bower_components/ionic/release/js/ionic-angular.js"></script>
    <script src="bower_components/ngCordova/dist/ng-cordova.js"></script>
    

    see the last line. If that does not help we need more information. Post your index html code and the full error you get that you left out after 'due to:'...