Error picking Phase name - IONIC

Asked

Viewed 17 times

1

Good evening, I am developing an app in Ionic, I created the function to check the correct answer, but in the line that would appear the area being displayed (message+='

  • '+this.processo.NOME_AREA.toLowerCase()+'
  • '). Create an Alert written Undefined. I checked and my query in the past is working by returning the name of the area.

    My Component:

    import { Homepage } from './.. /home/home'; import { Calculosprovider } from './.. /.. /providers/calculi/calculi'; import { Areaprovider } from './.. /.. /providers/area/area'; import { Component } from '@angular/core'; import { Ionicpage, Navcontroller, Toastcontroller, Modalcontroller, Alertcontroller } from 'Ionic-angular'; import { Processoprovider } from '.. /.. /providers/process/process'; import { Tabspage } from '.. /tabs/tabs';

    @Ionicpage() @Component({ selector: 'page-area', templateUrl: 'area.html', }) export class Areapage {

    public codeAreaChooded: number; public acertos: number of hits; public attempts: number; public errors: number;

    //on android public areas: any[];

    //on the computer /* public areas = [ { NAME: "AREA 1", CODIGO_AREA: 1 },

    {
      NOME: "AREA 2",
      CODIGO_AREA: 2
    },
    
    {
      NOME: "AREA 3",
      CODIGO_AREA: 3
    }
    

    ]; */

    //on android

    public process = { NAME: "", CODIGO_PROCESO: "", CODIGO_AREA: 0, NOME_AREA: "" };

    //on the computer /* public process = { NAME: "TRANSITION AND COMPONENT TERMINATION PROCESS FOR TCC", CODIGO_PROCESO: 1, CODIGO_AREA: 2, NOME_AREA:"INCISION" }; */

    constructor(public navCtrl: Navcontroller,public modalCtrl : Modalcontroller,public alertCtrl:Alertcontroller, private Toast: Toastcontroller, private areaProvider: Areaprovider, private calculosProvider: Calculosprovider, private processoProvider: Processoprovider) {

    this.acertos = 0;
    this.tentativas = 0;
    this.erros = 0;
    this.refresh();
    

    }

    ionViewDidEnter() { Let elem = Document.querySelector(".tabbar"); if (elem != null) { elem.style.display = 'None'; } }

    presentConfirm() { Let Alert = this.alertCtrl.create({ title: 'Leaving the App', message: 'Are you sure you want to quit? ',

      buttons: [
        {
          text: 'CANCELAR',
          role: 'CANCELAR',
          handler: () => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'SIM',
          handler: () => {
            //this.navCtrl.pop(HomePage);
            //this.navCtrl.push(HomePage);
            this.navCtrl.setRoot(HomePage);
    
          }
        }
      ]
    });
    alert.present();
    

    }

    refresh() {

    // no android
    this.getAreas();
    this.getProcessoAleatorio();
    

    }

    getAreas() { this.areaProvider.getAll() . then(result: any[]) => { this.areas = result; //this.toast.create({ message: "Areas successfully loaded.", Duration: 1000, position: 'Botton' }). present(); }) . catch() => { //this.toast.create({ message: 'Error loading areas.', Duration: 1000, position: 'Botton' }). present(); });

    }

    getProcersAleatorio() { Let processoAleatorio = this.calculosProvider.getRandomInt(1, 48);

    this.processoProvider.getByIdArea(processoAleatorio)
      .then((result: any) => {
        this.processo.NOME = result.NOME;
        this.processo.CODIGO_PROCESSO = processoAleatorio;
        this.processo.CODIGO_AREA = result.CODIGO_AREA;
        this.processo.NOME_AREA = result.NOME_AREA;
        //this.toast.create({ message: "Processo carregado", duration: 1000, position: 'bottom' }).present();
      })
    

    }

    send() {

    if (this.processo.CODIGO_AREA == this.codigoAreaEscolhida) {
    
      //this.toast.create({ message: 'Parabéns, você acertou', duration: 900, position: 'bottom' }).present();
      this.acertos++;
    
    } else {
      //this.showErrou();
      this.erros++;
      //this.toast.create({ message: `Você errou! A área correta é :  ${this.processo.NOME_AREA}`,
       //duration:2500, position: 'botton' }).present();
       this.showErrou();
    }
    this.tentativas++;
    this.refresh();
    

    }

    showErrou() { Let message= 'The response is incorrect'; message+='

  • '+this.processo.NOME_AREA.toLowerCase()+'
  • ';

    mensagem+="</ul>"
    
    let alert = this.alertCtrl.create({
      title: '<font color="red">Resposta Errada!</font>',
      subTitle: mensagem,
      buttons: ['CONTINUAR']
    });
    alert.present();
    

    }

    areaSchool(codeArea: number) { this.codigoAreaEscolhida = codigoArea; console.log(this.code); }

    }

    My predecessor:

    import { Injectable } from '@angular/core'; import { Sqliteobject} from '@Ionic-Native/sqlite'; import { Databaseprovider} from '.. /database/database';

    @Injectable() export class Processoprovider {

    constructor(private databaseProvider:Databaseprovider) { console.log('Hello Processoprovider Provider'); }

    public getById(id:number){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { //Let sql = 'select p., f. name the NOME_FASE from process p, phase f Where p.codigo_process = ? and p.codigo_phase = f.codigo_phase'; Let sql='select p., f. name the NOME_FASE, a.name the NOME_AREA from process p, phase f, area a Where p.process code = ? and p.codigo_phase = f.codigo_phase and p.codigo_area = a.codigo_area'; Let data = [id]; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let item = data.rows.item(0); Return item; } Else { Return null; } }) . catch(e)=>console.error(e)); }) . catch(e)=>console.error(e)); }

    public getAll(){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { Let sql = 'select p.* from process p Where p.codigo_process'; Let data = []; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let processes:any[] = []; for (var i=0;iconsole.error(e)); }) . catch(e)=>console.error(e)); }

    public getByIdArea(id:number){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { Let sql = 'select p.*, a.name as NOME_AREA from process p, area a Where p.codigo_process = ? and a.codigo_area = p.codigo_area'; Let data = [id]; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let item = data.rows.item(0); Return item; } Else { Return null; } }) . catch(e)=>console.error(e)); }) . catch(e)=>console.error(e)); }

    public getByNotArea(code_area){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { Let sql = 'select p.* from process p Where p.codigo_area <> ? '; Let data = [code area]; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let processes:any[] = []; for (var i=0;iconsole.error(e)); }) . catch(e)=>console.error(e)); }

    public getByArea(id:number){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { Let sql = 'select p.* from process p Where p.codigo_area = ? '; Let data = [id]; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let processes:any[] = []; for (var i=0;iconsole.error(e)); }) . catch(e)=>console.error(e)); }

    public getByIdFase(id:number){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { Let sql = 'select p.*, a.name the NOME_FASE from process p, phase a Where p.codigo_process = ? and a.codigo_phase = p.codigo_phase'; Let data = [id]; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let item = data.rows.item(0); Return item; } Else { Return null; } }) . catch(e)=>console.error(e)); }) . catch(e)=>console.error(e)); }

    public getByFase(id:number){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { Let sql = 'select p.* from process p Where p.codigo_phase = ? '; Let data = [id]; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let processes:any[] = []; for (var i=0;iconsole.error(e)); }) . catch(e)=>console.error(e)); }

    public getByNotFase(code_phase){ Return this.databaseProvider.getDB() . then(db:Sqliteobject) => { Let sql = 'select p.* from process p Where p.codigo_phase <> ? '; Let data = [code_phase]; Return db.executeSql(sql,data) . then(date:any) => { if(data.rows.length > 0){ Let processes:any[] = []; for (var i=0;iconsole.error(e)); }) . catch(e)=>console.error(e)); }

    }

    No answers

    Browser other questions tagged

    You are not signed in. Login or sign up in order to post.