Forms on Ionic [closed]

0

** Ionic **

I am developing an assistance app for my school, one of the pages, it has a button to add, I want that when I press the button, it takes me to a form, where you can put your name and surname, and when you click on the button that says "send", this will take me to the page that has the add + button, and add the name and surname as a card.

Image: link

    
asked by Nahuel Akeen Reymundo 09.03.2018 в 22:36
source

2 answers

1

You can do it with a modal: ModalController , ModalComponent

In the modal you must load the form (it can be another page), and then when recording the form you can return some value or variable. From the page where you have the +, you hear the onDidDismiss event of the modal, and so you can get the answer: Ex:

home.ts

...
public mostrarFormularioModal() {
  let formularioModal = this.modalCtrl.create(formularioPage);
  formularioModal.onDidDismiss(respuesta => {
    if(respuesta) {
      mostrarDatosEnTarjetas();
    }
  });
  formularioModal.present();
}

public mostrarDatosEnTarjetas() {
   //mostrar los datos en tarjetas
}
...

form-page.ts

...
public grabarFormulario() {
  //grabar los datos del formulario
  this.viewCtrl.dismiss(true);
}
...

Ionic has very good documentation, you should check it out.

    
answered by 10.03.2018 в 03:37
0

// Form

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


@IonicPage()
@Component({
  selector: 'page-añadir11',
  templateUrl: 'añadir11.html',
})
export class Añadir11Page {

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

  ionViewDidLoad() {
    console.log('ionViewDidLoad Añadir11Page');
  }


}

// Page with the + button

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Añadir11Page } from "../añadir11/añadir11";



@IonicPage()
@Component({
  selector: 'page-manana11',
  templateUrl: 'manana11.html',
})
export class Manana11Page {

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

  ionViewDidLoad() {
    console.log('ionViewDidLoad Manana11Page');
  }

subir(){
  this.navCtrl.push( Añadir11Page );

}


}
    
answered by 11.03.2018 в 04:04