本文介绍了在Angularjs2中删除* ngFor和* ngIf的DOM注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当没有要渲染的元素时,是否可以删除使DOM为"* ngIf"或"* ngFor" AngularJS2的注释?
Is it possible to remove comments that makes the DOM "*ngIf" or "*ngFor" AngularJS2 when there isn't an element to render?
也许可以将其设置在某个地方而不知道.我希望DOM尽可能整洁,而不会看到这样的注释:
Maybe it's possible to set this up somewhere and not know. I would have the DOM as clean as possible and not see comments like this:
<!--template bindings={}-->
推荐答案
它们是占位符,因此Angular知道在哪里渲染元素.例如,当您引用的集合为空然后添加数据时,Angular需要知道在哪里呈现第一个模板项目.
They are placeholders so Angular knows where to render elements.For example when the collection you refer to is empty and then add data Angular needs to know where to render the first template item.
这篇关于在Angularjs2中删除* ngFor和* ngIf的DOM注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!