I have an if-else
within my main controller:
var entity = shareDataService.getModalEntity();
if (entity = "NULL" || entity.length === 1) {
myDataPromise = getDataService.getDataFromREST(security);
console.log("HERE")
} else {
myDataPromise = $q.all(getDataService.keepICorrect(security));
console.log("THERE")
};
It takes entities
data from a service, shareDataService
.
It works fine when entity.length === 1
or entity === "NULL"
, but when the array is of length
2 or more, the condition does not pass it to the else
. I cannot work out for the life of my why, I have debugged just before the if-else
to check the value passed to the controller's function, and the array is definitely of length
2+ when I intend it to be. Also debugging entity.length
just before the if-else
shows the correct length of the array. What am I missing?