I am trying to update ng-class with a CSS class that has a specific background image. For example:
<button id="search" ng-class="{travel: travel }">Search</button>
for(var i = 0; i < arrayLength; i++) {
var descriptions = uniqueFilters[i].split(' ');
if(descriptions.indexOf('Travel') > -1) {
$scope.travel = "travel";
} else {
}
}}
I receive an array of strings. I take the strings, split the sentences into individual words, and then if they have a specific word, update the class to apply a specific background image.
How do I get this to work?
ng-class, it needs to be abooleanvalue, not astring. Maybe do something like:if(descriptions.indexOf('Travel') > -1) {$scope.travel = true;} else {}}