删除 Angular JS 中的辅助 HTML 注释? [英] Remove helper HTML comments in Angular JS?

查看:37
本文介绍了删除 Angular JS 中的辅助 HTML 注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法阻止 Angular 创建助手"HTML 注释?例如,

Is there a way to prevent Angular from creating "helper" HTML comments? For example,

<div ng-include="myTemplate"></div>

会变成类似的东西

<!-- ngInclude: 'hurr-durr.html' -->
<div ng-include="myTemplate"></div>

我该如何阻止?我查看了 Angular 源代码,我已经看到这些助手"是由几乎每个指令中的无条件 document.createComment 生成的,所以我想没有办法通过在供应商什么的.但也许有一些没有助手"的自定义 Angular 构建?我想我可以编写一些 Yeoman/Grunt 任务来从 Angular 的源代码中删除/注释 .createComment-s,每当我搭建一个新项目时.或者也许你们知道已经这样做的小提琴?而且,这提出了我的最后一个问题:这些评论是否对 Angular 的正常运行至关重要?如果我删除它们,会不会导致我的应用程序不稳定?应该重写 CSS 并处理它"吗?

How do I stop this? I've looked into the Angular source, and I've seen these "helpers" are generated by an unconditional document.createComment inside almost every directive, so I guess there's no way to stop them all at once by using a config setting on a provider or something. But maybe there is some custom Angular build without "helpers"? I suppose I could write some Yeoman/Grunt task to remove/comment the .createComment-s from Angular's source whenever I scaffold a new project. Or maybe you guys know of a fiddle that already does that? And also, this raises my last question: Are those comments somehow crucial to the Angular's normal functioning? And if I remove them, will it cause some kind of instability in my app? Should a just rewrite the CSS and "deal with it"?

推荐答案

注释对于 Angular 如何处理某些元素至关重要.删除它们目前不是一种选择.你有什么问题?

The comments are crucial to how Angular handles certain elements. Removing them is not currently an option. What issues are you having with it?

这篇关于删除 Angular JS 中的辅助 HTML 注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆