Uncaught ReferenceError: vira1 is not defined

0

I am creating a function but when it is called says that it has not been defined yet, what would be the reason?

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';

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

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

 
}
function vira1(){
	document.getElementById("vira0").style.zIndex = "999";
}
<ion-header>
</ion-header>


<ion-content padding class="bgcMemoria">
  <div class="fase1">
    <div class="viradasBaixo">
      <img src="assets/img/carta.jpg" id="viradaBaixo1" onclick="vira1()">
    </div>
    <div class="viradasCima" id="viradasCima">
      <img src="assets/img/virada.jpg" id="vira0"></img>
    </div>
  </div>
</ion-content>
    
asked by anonymous 15.10.2017 / 09:11

1 answer

1

From 2 to make binding of events, use parentheses, every time you want to call an event, (evento)="exeFuncao()"

Some events:

(focus)="exeFuncao()"
(blur)="exeFuncao()"

(submit)="exeFuncao()"

(scroll)="exeFuncao()"

(cut)="exeFuncao()"
(copy)="exeFuncao()"
(paste)="exeFuncao()"

(keydown)="exeFuncao()"
(keypress)="exeFuncao()"
(keyup)="exeFuncao()"

(mouseenter)="exeFuncao()"
(mousedown)="exeFuncao()"
(mouseup)="exeFuncao()"

(click)="exeFuncao()"
(dblclick)="exeFuncao()"

(drag)="exeFuncao()"
(dragover)="exeFuncao()"
(drop)="exeFuncao()"

You can see the complete list at article at Mozilla in>.

Another error is that your vira1 method is outside the JogomemoriaPage class so it will not work.

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';

@Component({
    selector: 'page-jogomemoria',
    templateUrl: 'jogomemoria.html',
})
export class JogomemoriaPage {
    constructor(public navCtrl: NavController, public navParams: NavParams) {
    }
    vira1(){
        document.getElementById("vira0").style.zIndex = "999";
    }
}
    
15.10.2017 / 09:31