Hi I'm new to ionic and I have the following html and js code. I am trying to get the value of user input on textbox upon clicking on the button. (If possible, I would like to store it into an object or a local cache so that it could be use throughout the same session)
<ion-navbar *navbar hideBackButton>
<ion-title>Welcome</ion-title>
</ion-navbar>
<ion-content>
<ion-list>
<ion-item>
<ion-label floating>Please enter a nickname</ion-label>
<ion-input type="text" value=""></ion-input>
</ion-item>
</ion-list>
<div padding>
<button (click)="login()" primary block>Continue</button>
</div>
next my .js code
import {Component} from "@angular/core";
import {MenuController, NavController, Alert} from "ionic-angular";
import {Index} from "../index/index";
@Component({
templateUrl: 'build/pages/login/login.html'
})
export class Login {
static get parameters() {
return [[MenuController], [NavController]];
}
constructor(menu, nav) {
this.menu = menu;
this.menu.swipeEnable(false);
this.nav = nav;
}
login() {
let alert = Alert.create({
title: 'You have entered',
message: 'Hello',
buttons: [
{
text: 'Cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Ok',
handler: () => {
console.log('Ok clicked');
console.log(getElementById('nickname'));
// this.menu.swipeEnable(true);
// this.nav.pop(Login);
// this.nav.setRoot(Index);
}
}
]
});
this.nav.present(alert);
}
}