JS | AngularJs | Show page when checking a checkbox

0

I need you to check a checkbox, this will take you to a page. But I get an error: funcion is not defined MY CODE home.html

<ion-header>
  <ion-navbar>
    <ion-title>
      Selecciona tu ciudad
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content >
  <ion-list>
    <ion-item>
      <ion-label>Concepcion del Uruguay</ion-label>
      <ion-checkbox onclick="funcion()" type="checkbox" id="cdelu"></ion-checkbox>
    </ion-item>
  </ion-list>
</ion-content>

and my home.ts PD: The error occurs here

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CdeluPage } from '../cdelu/cdelu'
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController) {


  function funcion(){ //Aqui esta el error
    var checkbox = document.getElementById("cdelu") as HTMLInputElement;

    if (checkbox.checked == true){
      this.navCtrl.push(CdeluPage);
    }

  }
  }
}
    
asked by Nahuel Akeen Reymundo 09.09.2018 в 18:40
source

1 answer

1

Remove the term function from your role:

funcion(){
    var checkbox = document.getElementById("cdelu") as HTMLInputElement;

    if (checkbox.checked == true){
      this.navCtrl.push(CdeluPage);
    }

}
    
answered by 10.09.2018 в 16:10