Initiating an Ion 2 AlertController on the same page gives this error: Not shown (in promise): the inserted view has already been destroyed
I would like it to run several times, equal to the instance of the ionic 1 alert, which can be called several times on the same page.
Code:
export class ConsultaProdutoPage { public usar_leitor: boolean = false; public codigo: string = ''; public icon: object = { 'icon': 'search', 'text': 'Buscar' }; public mostrar_produto: boolean = false; private loading; private _alert: Alert; constructor(public navCtrl: NavController, public navParams: NavParams, private _barcodeScanner: BarcodeScanner, private _alertCtrl: AlertController, private _service: consultaProdutoService, private _loadingCtrl: LoadingController) { this.loading = this._loadingCtrl.create({ content: 'Buscando Produtos. Aguarde...', dismissOnPageChange: true }); this._alert = this._alertCtrl.create({ 'title': "Aviso", 'message': 'Erro ao buscar produtos.', buttons: ['OK'] }); } buscaProduto(codigo) { this.loading.present(); this._service.getProduto(this.codigo) .then(success => { console.log(success); }) .catch(err => { this.loading.dismiss(); this.codigo = ''; this._alert.present(); }); } }
source share