How to use an ng-class in the html tag

0

I'm using the AngularJS framework and I need my tag to receive a dynamic class example:

<html lang="en" id="ng-app" ng-app="app" ng-class="app.title">
</html>

This app.title will receive a mongo value.

Can anyone tell me if this is possible? And if so, is it possible to return the class name knowing that I have a string in that field?

    
asked by anonymous 30.12.2014 / 18:37

1 answer

1

Translating from Angularjs documentation ( link )

The ngClass directive allows you to dynamically change the CSS of an HTML element by making a 'databinding' of an expression representing all classes to be added. The policy operates in three different ways, depending on which of the following three types the expression evaluates:

  • If the expression is a string, the string must contain several classes separated by spaces;
  • If the expression is an array, each element of the array must be a string with one or more classes separated by spaces;
  • If the expression is an object, then for each key-value item of the object the corresponding key will be used as the class name.
  • See this plunker as an example: link

        
    04.02.2015 / 20:56