Uncaught TypeError: Cannot read property 'find' of undefined


#1

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:


#2

someone help me please :frowning:


#3

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


#4

Yes It’s Included …!!


#5

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


#6

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
}


#7

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


#8

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