I don’t understand how to passe a click button data to another ts file by using a providers file.
So i want to control 4 share button by from home.html, i’m trying to pass the data from the home.html -> home.ts -> Popovershare.ts
I added a share button inside a square button thanks to a poppvers.
And when i try to call the home function directly to popovers.ts “constructor(here)” i got several errors.
This is my home.html
<button icon-only (click)="click(1)">
<button icon-only (click)="click(2)">
<button icon-only (click)="click(3)">
<button icon-only (click)="click(4)">
This is my home.ts
click(myEvent) {
this.indexNumber = myEvent
let numbr_select
if (this.indexNumber == 1) {
numbr_select = 1
}
if (this.indexNumber == 2) {
numbr_select = 2
}
if (this.indexNumber == 3) {
numbr_select = 3
}
if (this.indexNumber == 4) {
numbr_select = 4
}
}
this.indexNumber = numbr_select
this.shareprovider.ValueFonction(this.indexNumber)
let popover = this.popoverCtrl.create(PopoversharePage, {
}, {
cssClass: 'csspopover'
});
popover.present({
ev: myEvent
});
}
this is my shareprovider.ts
template: `
<ion-grid>
... share button with (click)="shareclick()"
</ion-grid>
constructor() {
this.ValueFonction()
}
ValueFonction(Number_selected?: any) {
for (let i = 1; i < 7; i++) {
if (Number_selected == i) {
// console.log(Number_selected, 'Valeur')
}
}
return Number_selected
}
And this is my Popovershare.ts
let i
for (let i = 0; i < 5; i++) {
switch (i) {
case 0:
this.ShareProvider.ValueFonction(1)
alert(1)
break;
case 1:
this.ShareProvider.ValueFonction(2)
alert(2)
break;
case 2:
this.ShareProvider.ValueFonction(3)
alert(3)
break;
case 3:
this.ShareProvider.ValueFonction(4)
alert(4)
break;
}
}
In these codes, it show in the console the number that i assigned for each button but when i try to call from popovers.ts to shareprovider.ts with this
this.ShareProvider.ValueFonction(4)
all alert run at the same time, i don’t understand why.
I just want to control the `hareclick() but this button is in another file ts, hope you understand.
Thanks for your attention !