Creating contact in ionic 2

Creating contact in ionic 2

In my previous tutorial we are fetching contact from the mobile device. Here is tutorial link click here.

In this tutorial we are creating contact using ionic 2.

In this tutorial we are using latest version of ionic that is ionic 2. New version of ionic was released with many new features with resolved many bug.

Before We start make sure your ionic is updated with ionic 2. If not then update ionic with following command

Let’s start with creating fresh new ionic 2 blank project

Got to project folder

Adding platform

After that install cordova Contacts plugin

This cordova contacts plugin provide native functionality for accessing and creating contact to mobile device

Open home.ts from createcontact\src\pages\home

In above code we have imported Contacts, Contact, ContactField, ContactName from ionic-native library of ionic.

Here addcontact() function fire after click on button. In this function using .save() method we are saving contact in device.

Let’s move to html stuff

Open home.html from createcontact\src\pages\home

In above html we have created two text field that is name and number for saving information in contact list.  After clicking on insert button addcontact() function will fire from home.ts.

Now time for checking app in real device.

Be the first to comment

Leave a Reply