0

I'm testing an Angular Directive where I use $compile to create an instance of the directive in the DOM. The markup for the element which the directive is attached to uses an ng-class with an expression inside. The special characters for that expression are being turned into their "safe" equivalents.

<article my-directive
    ng-class="(selectedItems.length > 1 && asset.selected === true) ? 'class1' : 'class2'">
 </article>

Looking at the HTML output by the $compile in the test:

'ng-class="(selectedItems.length &gt 1 &amp&amp asset.selected === true) ? class1: class2"'

1 Answer 1

0

This is valid HTML :)

When you $compile() or angular.element() string like this

<article my-directive ng-class="(selectedItems.length > 1 &amp;&amp; asset.selected === true) ? 'class1' : 'class2'"></article>

yo get proper HTML.

Some play-around with this issue: http://jsfiddle.net/ulfryk/vzz3x6py/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.