0

I'm beginner in development Cordova AngularJS. I use $localStorage to persist data. I use like this:

$http.get('http://127.0.0.1:8080/elodieService/evenements/' + $localStorage.idcategorie, {
    params: {
        fields: "titre_annonce,texte_annonce,adresse,imageJson",
        format: "json"
    }
}).then(function(result) {
    $localStorage.listEventParCategorie = result.data;
});

It's good, it works but now i want to check this condition

if ($localStorage.'listEventParCategorie' + idcategorie == null) {

}

e.g.: I concatenated listEventParCategorie with idcategorie to have $localStorage dynamic but is not worked. Please help me.

Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34
Rim Bejaoui
  • 329
  • 6
  • 30

1 Answers1

0

You should use bracket notation in your if condition:

if ($localStorage['listEventParCategorie' + idcategorie] == null) { ... }
Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34