我正在尝试Angular.js的内联模板。 我希望有一种方法可以在呈现html页面时通过打印到控制台来调试Angular对象。
内联模板将html模板放在脚本标记内。例如:
<script type="text/ng-template" id="/htmlpage.html">
<div class="page-header">
<h1>Title</h1>
</div>
<!-- everything else here is html too -->
</script>
这很棘手,因为脚本标签内的东西不再是JavaScript了。 所以我不知道如何使用内联模板打印到htmlpage.html内的控制台。
我已经尝试但是嵌套脚本标记失败了:
<script type="text/ng-template" id="/htmlpage.html">
<!-- html page template Angular stuff before is okay -->
<script>console.log("this line DOESN'T SHOW UP anywhere");</script>
<!-- html page template Angular stuff AFTERWARDS ALL FAIL-->
</script>
我也试过抛出一个裸的console.log,因为它在一个脚本标签内。
<script type="text/ng-template" id="/htmlpage.html">
<!-- rest of html page template is okay -->
console.log("this entire line gets output as text on the html page");
<!-- rest of html page template is okay -->
</script>
但整条线, console.log("this entire line gets output as text on the html page");
,打印到html页面,而不是控制台!