[solved] .dismiss() button close Modal error

Hello, i have a problem with Close button modal. (click)=“fechar()”

(Modal File)

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

  selector: 'conta',
  templateUrl: 'conta.html',
export class conta {
  loading: any;
  conta: any;
  descricao: any;
  constructor(public navCtrl: NavController, public navParams: NavParams, public ViewController: ViewController) {
      this.conta = this.navParams.get("parametro") || {descricao: "Spifa"};
  fechar() {
  salvar() {
  ionViewDidLeave() {
    this.ViewController.dismiss().catch(() => console.log('Some bug going on..'));

(Modal HTML)

  Generated template for the Conta page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.

    <ion-buttons start>
      <button ion-button navPop (click)="fechar()">
        <ion-icon [name]="'close'" ></ion-icon>


<ion-content padding>
        <ion-label Stacked>Descrição</ion-label>
        <ion-input type="text" [(ngModel)]="conta.descricao"></ion-input>
   <button ion-button full (click)="salvar()">Salvar</button>


I’m guessing that’s due to the fact you’re putting the ViewController in your Constructor with a capital V. Change it to public viewCtrl: ViewController

and your fechar Function to viewCtrl as well. What is dat navPop doing on your button? I don’t think thats necessary: <button ion-button navPop (click)="fechar()">

1 Like

the problem is navPop, i remove this from html and work correct. thank you help.