清洁angularjs输出到普通的HTML

时间:2014-09-12 13:41:37

标签: html angularjs code-cleanup

我正在按照一个教程尝试学习角度,但我得到的方式更混乱代码说明是否有一个标志我需要激活/停用我想生成干净的HTML打开其他建议后处理等< / p>

代码:

<ul>
<li ng-repeat="day in [1,2,3,4,5,6,7]">Name of the day: {{ ['Mon', 'Tue', 'Wed', 'Thu',   'Fri', 'Sat', 'Sun'][day-1] }}</li>
</ul>

预期产出:

<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>

1 个答案:

答案 0 :(得分:1)

您不应该担心HTML代码在浏览器端的外观如何。仅仅因为它适用于浏览器。您应该担心HTML部分/模板在源代码管理中的外观 - 因为这是供开发人员阅读和修改的。

此外,还有一种广泛使用的HTML minification task,它使HTML代码对人眼来说更难以阅读。但是,再一次,这是针对浏览器的 - 不要担心它。