chovy
chovy

Reputation: 75656

remove angular comments from html

Is it possible to remove or disable the HTML comments angular produces?

<ol class="items">
    <!-- ngRepeat: item in list | orderBy:'time':true -->
</ol>

Its breaking CSS rules that use :empty pseudo class.

ol:empty {
    content: "No results";
}

In order for the rule to be applied, there needs to be no whitespace or comments:

<ol></ol>

Upvotes: 7

Views: 3134

Answers (4)

Andrei
Andrei

Reputation: 69

$compileProvider.debugInfoEnabled(false);

But it can broke some plugins which have references on angular comments.

Upvotes: 2

chovy
chovy

Reputation: 75656

I ended up adding a class .empty with ng-class="{ empty: !list.length }" and applying the CSS rule that way without relying on the pseudoelement :empty.

Upvotes: 3

MarcusTzaen
MarcusTzaen

Reputation: 16

The content property is used with the :before and :after pseudo-elements

you can try this

Upvotes: 0

Dryden Long
Dryden Long

Reputation: 10182

While not the most efficient or direct way to do it, you could use javascript to remove the contents of the elements. Something like this should work:

document.getElementsByClassName('items').innerHTML = "";

I don't know what kind of structure you have, but I'm sure you could sneak this in before the CSS is loaded...

Edit

After reading the post linked by @zsong and this post here, you might end up breaking Angular trying to do this. Only one way to find out I guess!

Upvotes: -1

Related Questions