Search code examples
ionic-frameworkngcordova

Adding Full Contact details in Ionic Framework


In the official documentation of contacts in ngCordova, it only says $scope.contactForm, in other example (link below) only show how to add display name. how can I add fields like phone number email, address etc...

module.controller('MyCtrl', function($scope, $cordovaContacts) {
  $scope.addContact = function() {
    $cordovaContacts.save($scope.contactForm).then(function(result) {
      // Contact saved
    }, function(err) {
      // Contact error
    });
  };

  // Many more features will be added shortly
});

https://blog.nraboy.com/2014/11/create-delete-search-contacts-ionic-framework/ http://ngcordova.com/docs/plugins/contacts/


Solution

  • $scope.contactForm = {
    
        "displayName": "jones",
        "name": {
            "givenName": "jones",
            "formatted": "jones "
        },
        "nickname": null,
        "phoneNumbers": [
            {
                "value": "99999999999",
                "type": "mobile"
            }
        ],
        "emails": [
            {
                "value": "xddf@dd.com",
                "type": "home"
            }
        ],
        "addresses": [
            {
                "type": "home",
                "formatted": "This Address, An Address",
                "streetAddress": "This Address, An Address"
            }
        ],
        "ims": null,
        "organizations": null,
        "birthday": null,
        "note": "",
        "photos": null,
        "categories": null,
        "urls": null
    }