I'm building an hybrid app for iOS and Android, and there is a section where I want to show the day. If you open the app on Tuesday, it will say Tuesday and so on. It is in spanish, so, where it says "Miércoles" it is Wednesday, but I wrote it manually, I want it to change so if today is Wednesday, it automatically changes.
I tried to change it using ng-bind and the following code:
var today = new Date();
if(today.getDay() == 0){
var hoy = "Domingo";
} else if(today.getDay() == 1){
var hoy = "Lunes";
}else if(today.getDay() == 2){
var hoy = "Martes";
}else if(today.getDay() == 3){
var hoy = "Miercoles";
}else if(today.getDay() == 4){
var hoy = "Jueves";
}else if(today.getDay() == 5){
var hoy = "Viernes";
}else if(today.getDay() == 6){
var hoy = "Sábado";
}
$scrope.variable = hoy;
It didn't work, no console errors or warnings.
You're declaring the same variable multiple times so the declarations after the first are ignored.
It would look nicer to use a weekday array like so: