Uncaught TypeError: Cannot read property 'find' of undefined

Hello everyone,

i have a problem in plugin contacts :

--------> app.js

$ionicPlatform.ready(function() {

$scope.getAllContacts = function() {

var opts = {
filter : ‘’,
multiple : true,
fields : [‘displayName’]
};

            if (ionic.Platform.isAndroid()) {
                opts.hasPhoneNumber = true;
              } 
              console.log($cordovaContacts); /* RESULT : 

Object {
clone: function(e)
find: function(n)
pickContact: function()
remove: function(n)
save: function(n)
proto: Object
}
*/
$cordovaContacts.find(opts).then(function (contactsFound) { // Uncaught TypeError: Cannot read property ‘find’ of undefined
$scope.contacts = contactsFound;
console.log(JSON.stringify(contactsFound));
});

});

--------> index.html

  • < script src=“js/ng-cordova.min.js”>
  • < ion-item ng-repeat=“con in contacts”>
    {{con.displayName}}

someone help me please :frowning:

someone help me please :frowning:

did you check the ngCordova.min.js is included ?

Yes It’s Included …!!

did you check the existence of the library in that path ?
if not downloaded it form https://github.com/driftyco/ng-cordova/archive/master.zip and find the ng-cordova.min.js and link it to js folder

thanks @AbdouWeber for your respond.

The file path points to an existing file

console.log($cordovaContacts);
RESULT :
Object {
clone: function(e)
find: function(n)
pickContact: function()
remove: function(n)
save: function(n)
proto: Object
}

Hi, did you solve the problem? I have the same issue. Thanks

2 Likes

are you check package.json?
maybe npm(cordova plugin) problem.