将angularjs输出为纯html
我正在跟随一个教程尝试学习angular,但我得到的代码比示例中说明的更混乱,是否有一个标志我需要激活/停用我想生成干净的html,对其他建议开放后处理等 代码:将angularjs输出为纯html,html,angularjs,code-cleanup,Html,Angularjs,Code Cleanup,我正在跟随一个教程尝试学习angular,但我得到的代码比示例中说明的更混乱,是否有一个标志我需要激活/停用我想生成干净的html,对其他建议开放后处理等 代码: 当天的名称:{{{{周一、周二、周三、周四、周五、周六、周日]} 预期产出: <ul> <li>Name of the day: Mon</li> <li>Name of the day: Tue</li> <li>Name of the day
当天的名称:{{{{周一、周二、周三、周四、周五、周六、周日]}
预期产出:
<ul>
<li>Name of the day: Mon</li>
<li>Name of the day: Tue</li>
<li>Name of the day: Wed</li>
<li>Name of the day: Thu</li>
<li>Name of the day: Fri</li>
<li>Name of the day: Sat</li>
<li>Name of the day: Sun</li>
</ul>
- 当日名称:星期一
- 当日名称:星期二
- 当日名称:星期三
- 当日名称:星期四
- 当日名称:星期五
- 当日名称:星期六
- 当日名称:太阳
实际产量:
<ul>
<!-- ngRepeat: day in [1,2,3,4,5,6,7] --><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Mon</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Tue</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Wed</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Thu</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Fri</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Sat</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Sun</li>
</ul>
日期:星期一日期:星期三日期:星期二>当日名称:星期四
您不应该担心HTML代码在浏览器端的外观。只是因为它是为浏览器设计的。您应该担心HTML部分/模板在源代码管理中的外观,因为这是供开发人员阅读和修改的
此外,还有一种被广泛使用的方法,这使得HTML代码对人眼来说更不可读。但是,这是针对浏览器的——不用担心。你不需要考虑输出的样子。它的行为类似于预期的输出,这是唯一重要的事情。Angular在内部需要这样的额外标记。你对此有什么问题吗?所以在没有添加标记的情况下是无法输出的?没有,也没有必要这样做。在angular接管之前,你所追求的干净代码应该是html/js。不是之后。谢谢你的输入,我知道你从哪里来,但不要相信它是黑白的。例如,我想使用angular的项目将为前端开发人员生成html样式,因此干净的标记非常重要。@MitchellBray,我明白你的意思。请注意,例如,如果您打开
chrome开发工具
,元素
选项卡,您将看到格式良好的HTML。您可以使用它,不是吗?是的,谢谢,但这不是太多的格式,而是添加的标记,我目前正在研究如何在保存之前使用正则表达式处理代码,但如果angular有最终输出选项,那就太好了。
<ul>
<!-- ngRepeat: day in [1,2,3,4,5,6,7] --><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Mon</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Tue</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Wed</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Thu</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Fri</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Sat</li><li ng-repeat="day in [1,2,3,4,5,6,7]" class="ng-scope ng-binding">Name of the day: Sun</li>
</ul>