Hello, I need help to change the class of a div when the url change, I want 
to do it in the controller - how do I do that?

I did a conditional statement on the div on data-ng-class and I want to 
somehow add this scope to the controller and specify when the url is 
/vegetarian to apply class 'egg' and i manually change url i want the class 
'bacon' to be applied

This is my attempt:

html:
<div data-ng-class="{'egg': isVeggie, 'bacon': !isVeggie }">
      Text here
    </div>


controller:

app.controller('foodCtrl', function ($scope, $location) {
  
  $scope.location = $location;
  
  $scope.isVeggie = function() {
    if(isVisitor === $location.path('/vegetarian')) {
      return true;
    }
  };
  
});

This is not working for me, please help

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to