These are chat archives for angular/angular-2-ionic-2

2nd
Mar 2017
redamania
@redamania
Mar 02 2017 06:46
hi everyone.. would it be possible to use php mailer on ionic app? or are there other alternatives
Idan & Carolina
@sayeko
Mar 02 2017 07:29
@redamania Why can't u simply send xhr request to your php backend and send the mail there?
Idan & Carolina
@sayeko
Mar 02 2017 07:54
Hi I would like to ask if someone can explain about the PWA of ionic app it quite not sound right. because for every ionic App we need to generate apk or ipa
redamania
@redamania
Mar 02 2017 09:06
@sayeko any idea on how should i be doing that? Sorry newbie here.
Sai Rahul
@rhhhhl
Mar 02 2017 12:03
Hi, I have a query... Can we use a alert controller inside a method in ionic 2
Actually I need to input a alert controller inside a button
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 12:09
You mean open alert box on the click of a button?
Sai Rahul
@rhhhhl
Mar 02 2017 12:22
Yes
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 12:30
Just stick the alert logic into the function that is called when click event occurs
template
<button ion-button (click)="foo()">
</button>

component
foo(){
let alert = this.alertController.create({options here})
alert.present()
}
Sai Rahul
@rhhhhl
Mar 02 2017 13:28
I have one if else statement already in a function which validates a reg ex after that, before else I need the alert controller to be called...
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 14:09
Code...
A. Tate Barber
@tatemz
Mar 02 2017 15:46
I'm using ionic2 and cannot run ionic serve due to this error:
Error: Cannot find module "js-data"
    at webpackMissingModule
Anyone seen this before? It seems to be related to driftyco/ionic-app-scripts#389
Sai Rahul
@rhhhhl
Mar 02 2017 15:56

@andrewgy8 // html

<button ion-button (click)="updateProfile()" [disabled]="disUpdate">Update Profile</button>

// .ts
import { AlertController,NavController,NavParams,Platform } from 'ionic-angular';

//providers
import { DataService } from '../../../../providers/DataService';
import { LocalStorageService } from '../../../../providers/LocalStorageService';
import { AlertService } from '../../../../providers/AlertService';

@Component({
selector: 'page-edit-profile',
templateUrl: 'edit-profile.html'
})

export class EditProfilePage {
name;phone;gender;def;items;data;obj;defDisable;disUpdate;otp;
constructor(public navCtrl: NavController, public navParams: NavParams,private ds:DataService,private local:LocalStorageService,public alertCtrl: AlertController,private alert:AlertService) {

   this.obj = JSON.parse(this.local.getUser());
   this.name=this.obj.name;
    this.phone=this.obj.phone;
    this.def = this.obj.default_home;
    this.gender = this.obj.gender;
    this.defDisable=false;

    this.disUpdate=true;

}
ionViewDidLoad() {
}

updateProfile(){

this.obj.default_home=this.def;
this.obj.name =this.name;
this.obj.phone =this.phone;
let re = new RegExp(/^[0-9]*$/);
    if(re.test(this.phone) && this.phone.length ==10 && this.name.length >= 3) {

   this.obj.gender=this.gender;



this.ds.putEditProfile(this.obj,data => {
      console.log(data);
      //toastHere
      this.navCtrl.pop();
      this.local.setUser(JSON.stringify(this.obj));
      this.local.setDefaultHome(this.def);
    }, error => {
        console.log(error);
        console.log(JSON.stringify(error.json()));
    });

    }
    else {
        console.log('Invalid');
            this.alert.showAlert("Error","Check Details");
    }

}

getOtpPassword(){
let alert = this.alertCtrl.create({
title: 'Enter OTP',
inputs: [

  {
    name: 'otp',
    placeholder: 'Enter OTP',
    type: 'otp'
  }
],
buttons: [
  {
    text: 'Cancel',
    role: 'cancel',
    handler: data => {
      console.log('Cancel clicked');
    }
  },
  {
    text: 'Submit',
    handler: data => {

    }
  }
]

});
alert.present();
}

}

getOtpPassword() inside there is a alert that i need after the select gender of updateProfile.. is it possible @andrewgy8

right now there are two buttons, i want only one button which does both validates and gives a alert pop up

[9:30]
i will delete the getOtpPassword() and inside that function there is a alert that i want inside the updateProfile() after the regex, choose gender, attributes... i want to how can i put is it possible to you if statement inside a if statement will the button do validate and give a pop up at the same time

Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 16:51
@rhhhhl If I understand what you are trying to do, your approach is not going to work. What you want is if the phone.lenght, phone patern and name length are valid then you can change the gender. Is that right?
Sai Rahul
@rhhhhl
Mar 02 2017 16:55
Yes
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 16:58
Unless you allow for the desired gender to be chosen before the validations are triggered you might be able to do something like this
this.obj.default_home=this.def;
this.obj.name =this.name;
this.obj.phone =this.phone;
let re = new RegExp(/^[0-9]*$/);
    if(re.test(this.phone) && this.phone.length ==10 && this.name.length >= 3) {


        this.alert.showAlert({pass options here to grab gender info})



// I would put the following logic into another function that is called in the handler param of the alert controller
        this.ds.putEditProfile(this.obj,data => {
                console.log(data);
                //toastHere
            this.navCtrl.pop();
            this.local.setUser(JSON.stringify(this.obj));
            this.local.setDefaultHome(this.def);
        }, error => {
            console.log(error);
            console.log(JSON.stringify(error.json()));
        });

    }
    else {
        console.log('Invalid');
        this.alert.showAlert("Error","Check Details");
    }
}
Sai Rahul
@rhhhhl
Mar 02 2017 17:03
1.png
2.png
i have no problem with selecting gender i want to get an alert(where i can input the OTP i will recieve) after the validation(that when the button can be clicked) is over
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 17:09
What? Just call showalert when you want it to show then.
Sai Rahul
@rhhhhl
Mar 02 2017 17:12

updateProfile(){

this.obj.default_home=this.def;
this.obj.name =this.name;
this.obj.phone =this.phone;
let re = new RegExp(/^[0-9]*$/);
    if(re.test(this.phone) && this.phone.length ==10 && this.name.length >= 3) {

   this.obj.gender=this.gender;

let alert = this.alertCtrl.create({
title: 'Enter OTP',
inputs: [

  {
    name: 'otp',
    placeholder: 'Enter OTP',
    type: 'otp'
  }
],
buttons: [
  {
    text: 'Cancel',
    role: 'cancel',
    handler: data => {
      console.log('Cancel clicked');
    }
  },
  {
    text: 'Submit',
    handler: data => {

    }
  }
]

});
alert.present();
}

this.ds.putEditProfile(this.obj,data => {
      console.log(data);

    }, error => {
        console.log(error);
        console.log(JSON.stringify(error.json()));
    });

    }
    else {
        console.log('Invalid');
            this.alert.showAlert("Error","Check Details");
    }
is this possible
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 17:13
Does it work?
Sai Rahul
@rhhhhl
Mar 02 2017 17:13
no
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 17:13
And what have you tried to fix it?
Whats the error?
Sai Rahul
@rhhhhl
Mar 02 2017 17:13
can i use it in if statement after the gender select statement
Andrew Graham-Yooll
@andrewgy8
Mar 02 2017 17:14
nested if/else statements, yes
Sai Rahul
@rhhhhl
Mar 02 2017 17:27
hey @andrewgy8 thanks for the help, i will try in diff direction this time
Idan & Carolina
@sayeko
Mar 02 2017 17:32
How to create app shell in ionic app?
Robert Lavoie AKA BobbyDigital
@rlavoie
Mar 02 2017 19:01
Is is common or possible to use standard angular2 routes instead of navController.push()??
Oliver Henrique
@oliverhm
Mar 02 2017 22:03
Hey guys
Someone knows how i could ios 10 local notifications works?