Typescript interface - Cannot invoke an expression whose type lacks a call signature

时间:2019-01-09 21:43:47

标签: typescript ionic-framework interface

I have a model called QClass

export interface QClass {
  rowid: number;
  Category: string;
  Question: string;
  Image: string;
  Option1: string;
  Option2: string;
  Option3: string;
  Option4: string;
  Answer: number;
}

I then have a database provider which returns the Promise

selectData(): Promise<QClass[]> {
    console.log('selectData Called')

    return this.database.executeSql('SELECT * FROM question ORDER BY rowid DESC', [])
      .then(res => {
        console.log('Selected from table SQL')
        for (var i = 0; i < res.rows.length; i++) {
          this.questions.push({ rowid: res.rows.item(i).rowid, Category: res.rows.item(i).Category, Question: res.rows.item(i).Question, Image: res.rows.item(i).Image, Option1: res.rows.item(i).Option1, Option2: res.rows.item(i).Option2, Option3: res.rows.item(i).Option3, Option4: res.rows.item(i).Option4, Answer: res.rows.item(i).Answer });
          console.log("Pushed item " + i + " - " + res.rows.item(i).Question);
        }
        return this.questions;
      })
  }

But then when i call this in my page it gives me the error "Cannot invoke an expression whose type lacks a call signature. Type 'QClass[]' has no compatible call signatures." on the line questions(i).Category

this.databaseprovider.selectData().then((questions) => {

      this.questions = questions;
      for (var i = 0; i < questions.length; i++) {
        console.log("Pushed item " + i + " - " + questions(i).Category);
      }
    });

Can You pls suggest the issue?

0 个答案:

没有答案
相关问题