My directive includes replace: true
in the definition.
<my-custom-tag>
</my-custom-tag>
This is the template for the directive:
<div data-ng-class="{'class1': condition1, 'class2': condition2}">
</div>
When using my directive like this, it generates an error:
<my-custom-tag data-ng-class="{'class3': condition3}"></my-custom-tag>
The error occurs because the template already defines a data-ng-class
attribute, resulting in the following HTML:
<div data-ng-class="{'class3': condition3} {'class1': condition1, 'class2': condition2}"></div>
Is there a way to merge these objects to avoid syntax errors during compilation?
Check out the Plunkr example, view the browser console for error messages, and inspect the element to examine the data-ng-class
attribute.