错误:无法找到名称' ContactField'在离子2

时间:2016-09-19 11:33:42

标签: cordova angular typescript cordova-plugins ionic2

我必须使用Ionic2保存联系人,但是当我使用cmd运行应用程序时,我收到错误。我已经安装了cordova-plugin-contacts

这是我的代码

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Contacts} from 'ionic-native';
@Component({
  templateUrl: 'build/pages/contact/user-add/user-add.html',
})
export class UserAddPage {
  name:any;
  number:any
  constructor(private navCtrl: NavController) {
  }
  addcontact(){
    var contact=Contacts.create();
    contact.displayName=this.name;
    contact.nickname=this.name;

    var contactfield=new ContactField();
    contactfield.type="mobile";
    contactfield.value=this.number;
    contactfield.pref=true;

    var numbersection=[];
    numbersection.push(contactfield);
    contact.phoneNumbers=numbersection;

    contact.save().then((data)=>{
      console.log('saved',data);
    },(error)=>{
      console.log('error',error);
    })
  }
}

之后我收到此错误

enter image description here

1 个答案:

答案 0 :(得分:1)

你只需要像这样导入它:

WITH ADMISSION_OUTSIDE AS 
(   .....
.....
)
SELECT CASE WHEN (SELECT COUNT(1) tot 
                  FROM ADMISSION_OUTSIDE) > 0 THEN 'OK' ELSE 'NOT OK' END