Sharing data between different pages


#1

Hello,
I would like to ask you something.
I have two pages
1.- login-form.ts (PAGE: Login -> component-> login-form.ts)

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

@Component({
    selector: 'login-form',
    templateUrl: 'login-form.html'
})
export class LoginForm {
    username = '';
    password = '';
    rememberme = false;

    public **username1** = 'mari@';
    public password1 = 'marimari';
  constructor(public navCtrl: NavController) {

  }

  login() {
      console.log('Loggin');
      console.log(this.username + ' - ' + this.password + ' - ' + this.rememberme);

      let testing = this.username1 === this.username && this.password1 === this.password;
      if(testing){
        console.log("Usuario Correcto");
      }else{
        console.log("Usuario Incorrecto");
      }
  }

}

2.- view-profile.html (PAGE: Profile -> component-> view-profile.html)

<ion-card>
    <ion-card-content>
        <ion-list>
            <img src="assets/img/user.png" />
            <ion-item>
                <ion-label>Razón Social:  </ion-label>
            </ion-item>
            <ion-item>
                <ion-label>Nombre: {{ **username1** }}</ion-label>
            </ion-item>
            <ion-item>

I need to obtain the data: “username1” that belongs with page “login”

I don’t know how to access to the value “username1” from other different page.


#3

Here’s a good article by Josh Morony:


#4

Thanks!! I got what I needed. Thanks for all!!:smiley: