Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "'CallLog' refers to a value, but is being used as a type here." when trying to use CallLog in a component #14

Open
cedricbonhomme opened this issue Jun 4, 2019 · 1 comment

Comments

@cedricbonhomme
Copy link

cedricbonhomme commented Jun 4, 2019

Hello,

I would like to use a callLog object in my component.

Below is my constructor:

import { Component } from '@angular/core';
import { Loading, LoadingController, AlertController } from 'ionic-angular';

@Component({
  selector: 'page-spam',
  templateUrl: 'spam.html'
})
export class SpamPage {
    constructor(public callLog: CallLog, public alertCtrl:AlertController, public loadingCtrl: LoadingController) { 
    ...
    <snap>
    ...
    }
}

Also CallLog is defined in the providers (app.components.ts).
And the error I get is:

Typescript Error
'CallLog' refers to a value, but is being used as a type here.

Also if I want to define a callLog variable outside the constructor I need to do it like this:

callLog: typeOf CallLog

I must use typeOf.

I do not know what I am doing wrong. I followed some tutorials and it does not help me. I am using Typescript 3.4.5.

Can someone help me ? Thank you!

@cedricbonhomme
Copy link
Author

For example this is not working:
https://github.com/ban-ban/newcallduration/blob/master/src/providers/group-list/group-list.ts#L19

I am able to make it work if I directly uses CallLog:

import { CallLog, CallLogObject } from '@ionic-native/call-log';

@Component({
  selector: 'page-spam',
  templateUrl: 'spam.html'
})
export class SpamPage {

    constructor(
        public alertCtrl:AlertController,
        public loadingCtrl: LoadingController) {

CallLog.requestReadPermission()
        .then(()=>{
            CallLog.getCallLog(filters)
            .then((data)=>{
                let duration:number = 0;
                for(let i=0; i<data.length;i++){
                    duration = duration+data[i].duration;
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant