ngCordova plugins doesn't work

Hello, I have a problem with ngCordova when I run any plugin method always returns the same error .
For example in $, return “TypeError: Cannot call method ‘download’ of undefined” . Or when I use $cordovaMedia.newMedia, return return “TypeError: Cannot call method ‘newMedia’ of undefined”, no matter plugin utilize, I always return the same error.

I have the cordova plugins installed and ‘ngCordova’ injected, as indicated in the documentation and I tested it on real android device.

Can someone help me out? :weary:

…Sorry for my bad english :relaxed:

Can you share some code?


this is my app.js

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
var main = angular.module('starter', ['ionic', 'ngCordova', 'ngSanitize'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
    if(window.StatusBar) {

main.directive('ngEnter', function () {
    return function (scope, element, attrs) {
        element.bind("keydown keypress", function (event) {
            if(event.which === 13) {
                scope.$apply(function (){

main.controller("Principal", ['$scope', '$http', function($scope, $http, $cordovaMedia, $timeout, $cordovaFileTransfer){
  $scope.searchinput = ""
  $scope.resultados = []
  $scope.spinerHTML ='<ion-spinner icon="dots"></ion-spinner>';
  var srcmp3 = ''
  var media;
  $scope.buscar = function (){
    url = ''
    $http.get(url, {params : { busqueda : $scope.searchinput }}).
        then(function(response) {
          $scope.resultados =['resultados']
        }, function(response) {

  $ = function (id){
    srcmp3 = ""+id;
    media = new Media(srcmp3, null, null, mediaStatusCallback); //this works
    // media = $cordovaMedia.newMedia(srcmp3); // doesn't work;

   var mediaStatusCallback = function(status) {
      if(status == 1) {
          //${template: 'Loading...'});
      } else {

  $scope.descargar = function (id, name, artist){

      var url = ""+id;
      var targetPath = cordova.file.documentsDirectory + name + "-" + artist + ".mp3";
      var trustHosts = true
      var options = {};

      $, targetPath, options, trustHosts)
        .then(function(result) {
          // Success!
        }, function(err) {
          // Error
        }, function (progress) {
          $timeout(function () {
            $scope.downloadProgress = (progress.loaded / * 100;


this is my index.html

<!DOCTYPE html>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/" rel="stylesheet">

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="js/ng-cordova.min.js" type="text/javascript"></script>
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
  <body ng-app="starter">

      <ion-header-bar class="bar bar-header bar-dark">
        <h1 class="title">Myapp</h1>
      <ion-content ng-controller="Principal">
        <div class="list list-inset">
          <label class="item item-input">
            <i class="icon ion-search placeholder-icon"></i>
            <input type="text" ng-model="searchinput" ng-enter="buscar()" placeholder="boogie wonderland">
        <div class="list" ng-repeat="list in resultados" ng-cloak>
            <a class="item item-thumbnail-left" href="#">
              <img ng-src="{{list.url_cover}}">
              <button class="button button-small button-assertive" ng-click="play('{{list.id_mp3}}')">
                <i class="ion-play"></i>
              <button class="button button-small button-assertive" ng-click="descargar('{{list.id_mp3}}', '{{list.titulo}}','{{list.artista}}')">
                <i class="ion-ios-cloud-download"></i>
      <ion-footer-bar align-title="left" class="bar bar-footer bar-balanced">
      <h1 class="title">Hola</h1>

PD: if execute cordova plugins without using ngCordova, works fine!

is your " js/ng-cordova.min.js " in right place ? last version ?

the version of ngCordova is the last v0.1.20-alpha (has been downloaded the sunday), and I think my file is in the right place…

Problem solved…

It’s necessary to make a change in the documentation of ngCordova, many examples are deprecated. I fix it, adding plugin to array injection and wrapped the call method plugin in the $ionicPlatform.ready function, for example:

main.controller("Principal", ['$scope', '$http', '$ionicPlatform','$cordovaMedia', function($scope, $http, $ionicPlatform, $cordovaMedia){
  $ = function (id){
    srcmp3 = ""+id;
    $ionicPlatform.ready(function() {
      var media = $cordovaMedia.newMedia(srcmp3);;

It’s important keep the order of arguments and dependencies and add the plugins that you need after add platform (not before)

Sorry for my bad english , I hope helped someone