Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
- import { RegisterPage } from '../register/register';
- import { Storage } from '@ionic/storage';
- import { HomePage } from '../home/home';
- import { TabsPage } from '../tabs/tabs';
- /* Generated class for the LoginPage page.
- *
- * See https://ionicframework.com/docs/components/#navigation for more info on
- * Ionic pages and navigation.
- */
- @IonicPage()
- @Component({
- selector: 'page-login',
- templateUrl: 'login.html',
- })
- export class LoginPage {
- username:string='';
- password:string='';
- usernamep:any='';
- passwordp:any='';
- constructor(public navCtrl: NavController, public navParams: NavParams, public alertCtrl: AlertController, public storage: Storage) {
- }
- ionViewDidLoad() {
- console.log('ionViewDidLoad LoginPage');
- }
- aut(){
- this.storage.get('username').then(
- (val)=>{
- this.usernamep = val;
- console.log('Username is Storage', val);
- });
- this.storage.get('password').then(
- (val)=>{
- this.passwordp = val;
- console.log('Password is Storage', val);
- });
- if(this.username == this.usernamep && this.password == this.passwordp)
- this.gotoHome();
- else
- this.showAlertfailed();
- }
- /*aut(){
- let data = {
- username: btoa(this.username),
- password: btoa(this.password)
- };
- if(data.status == 'true')
- {
- this.navCtrl.setRoot(HomePage);
- console.log('login berhasil');
- }
- else
- {
- this.showAlertsuccess('Login Gagal, username atau password anda salah');
- console.log('login gagal')
- }
- }*/
- showAlertsuccess(title) {
- let alert = this.alertCtrl.create({
- title: 'Confirmation!',
- subTitle: title,
- buttons: ['OK']
- });
- alert.present();
- }
- showAlertfailed() {
- let alert = this.alertCtrl.create({
- title: 'Confirmation!',
- subTitle: 'Login Failed!!!',
- buttons: ['OK']
- });
- alert.present();
- }
- gotoRegis(){
- this.navCtrl.push(RegisterPage);
- }
- gotoHome(){
- this.navCtrl.push(TabsPage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement