cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michiel Vermeersch (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-12600) @ionic-native/contacts Cannot read property 'create' of undefined
Date Fri, 24 Mar 2017 15:17:41 GMT

    [ https://issues.apache.org/jira/browse/CB-12600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15940521#comment-15940521
] 

Michiel Vermeersch commented on CB-12600:
-----------------------------------------

I have the current code that follows the ionic api
{code}
import {Component} from '@angular/core';
import {NavParams} from 'ionic-angular';
import {ContactUtil} from "../../utils/ContactUtil";
import {DMSContact} from "../../models/DMSContact";
import {Contact, Contacts, ContactField, ContactName} from '@ionic-native/contacts';

@Component({
  selector: 'page-detail',
  templateUrl: 'detail.html'
})
export class DetailPage {
  contact: DMSContact;

  constructor(public navParams: NavParams, public contactUtil: ContactUtil, private contacts:
Contacts) {
    this.contact = navParams.get('contact');
  }

  public exportContact() {
    let c: Contact = this.contacts.create();

    c.name = new ContactName(null, this.contact.lastName, this.contact.firstName);
    c.phoneNumbers = [
      new ContactField('home', this.contact.telExtern),
      new ContactField('mobile', this.contact.telGSM)
    ];
    c.emails = [
      new ContactField('work', this.contact.email)
    ];
    c.birthday = this.contact.birthDay;

    c.save().then(
      () => console.log(c),
      (error: any) => console.log(error)
    )
  }
}
{code}

But it still gives me the cannot read property create of undefined message;

> @ionic-native/contacts Cannot read property 'create' of undefined
> -----------------------------------------------------------------
>
>                 Key: CB-12600
>                 URL: https://issues.apache.org/jira/browse/CB-12600
>             Project: Apache Cordova
>          Issue Type: Bug
>            Reporter: Michiel Vermeersch
>            Assignee: Kerri Shotts
>              Labels: ionic
>
> Cannot read property 'create' of undefined
> when trying to:
> let c: Contact = this.contacts.create();
> contacts is declared in the constructor and included in providers under app.module.ts



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message