I wrote the following code:
<style>
.dotted {
border:dotted;
}
</style>
....
<p ng-style = "mystyle" ng-class="dotted "> {{ answer }} </p>
My purpose was that the
element will be put inside dotted border line. It doesn't work. I looked at Angular documentation (https://docs.angularjs.org/api/ng/directive/ngClass) and I saw that:
If the expression evaluates to a string, the string should be one or more space-delimited class names.
I understand that ng-class may contain a class name I defined inside -tag. So.. what am I doing wrong?
ng-classdirective evaluates its value againstscopeof DOM which is bound to, so heredottedget evaluated with scope and it doesn't have value. So you have to provide it as'dotted'(string)In your case you should directly use
class="dotted"as your class seems to be static.