javascript - ionic getting textbox value -


hi i'm new ionic , have following html , js code. trying value of user input on textbox upon clicking on button. (if possible, store object or local cache use throughout same session)

<ion-navbar *navbar hidebackbutton>      <ion-title>welcome</ion-title> </ion-navbar>  <ion-content>  <ion-list>      <ion-item>         <ion-label floating>please enter 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 .js code

 import {component} "@angular/core";  import {menucontroller, navcontroller, alert} "ionic-angular";  import {index} "../index/index";   @component({     templateurl: 'build/pages/login/login.html'  })  export class login {     static 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); }  } 

ionic works angular has 2 way binding core principal. there lots of way accomplish 1 way set model of html item. if set input have ng model

<ion-input type="text" value="" [(ngmodel)]="inputname"></ion-input> 

and in controller(class) you'll have

this.inputname; 

it hold value changes html.