my idea is that if today's date is greater than or equal to the expected date that the button directs to "x" or "y"...
I don't know where can I put this condition (if on file .ts or .html):
var expectedDate = new Date ("2022/08/11")
var dates = expectedDate.toString()
var today = new Date().toISOString().split('T')[0];
if(today >= expectedDate) {
microsoftLogin()
}
else{...
googleLogin()
}
Here is my code in .HTML where is my button Login I don't know if is possible to add the condition on (tap)
<Button
width="70%"
height="40"
(tap)="CONDITION HERE"
text="Iniciar sesión"
row="2">
</Button>
CodePudding user response:
I don't know much about native script but you should be able to make a method in your TS file and call it in the HTML
HTML file:
<Button
width="70%"
height="40"
(tap)="loginTapped()"
text="Iniciar sesión"
row="2">
</Button>
TS file:
loginTapped() {
var expectedDate = new Date ("2022/08/11")
var dates = expectedDate.toString()
var today = new Date().toISOString().split('T')[0];
if(today >= expectedDate) {
microsoftLogin()
}
else{...
googleLogin()
}
}
Hopefully this helps.
CodePudding user response:
This may help you.
TS:
expectedDate=null;
today=null;
onLogin() {
this.expectedDate = new Date('2022/01/11');
this.today =new Date();
if(this.today.getTime() > this.expectedDate.getTime())
{
// today is greater than expected
this.microsoftLogin()
}
else
{
// today is less than expected
this.googleLogin()
}
}
microsoftLogin()
{
// some function logic
}
googleLogin()
{
// some function logic
}
HTML:
<button
width="70%"
height="40"
(click)="onLogin()"
row="2">
Login
</button>