For the ngCordova Contacts plugin, the sample code to read/get all contacts without filtering is given as below:
$scope.getAllContacts = function() {
$cordovaContacts.find().then(function(allContacts) { //omitting parameter to .find() causes all contacts to be returned
$scope.contacts = allContacts;
}
};
Note the find()
method without any parameter. The comment beside it states, “//omitting parameter to .find() causes all contacts to be returned”
Apparently, the missing options argument seems to cause error for the Cordova plugin.
Thus I suspect we may still need this:
var opts = { //search options
filter : "", // Set to empty string to match any contact?
multiple: true // A search may return multiple contacts
}
// Still need the opts argument after all.
$cordovaContacts.find(opts).then(function(allContacts) {
$scope.contacts = allContacts;
}};
I believe there could be something wrong with the sample code, though I am not 100% sure. If someone can confirm this, it would be great.
Hope this helps someone facing weird error with it.