【问题标题】:Angular.js template to plain htmlAngular.js 模板到纯 html
【发布时间】:2014-03-02 23:12:58
【问题描述】:

我想知道是否可以将 Angular.js 模板编译为纯 html。例如。

//script.js
function TestCtrl($scope) {
    $scope.browsers = ['chrome', 'firefox', 'ie'];
}

// template.html
<div ng-app>
    <ul>
        <li ng-repeat="browser in browsers">{{browser}}</li>
    </ul>
</div>

收件人:

<div>
    <ul>
        <li>chrome</>
        <li>firefox</>
        <li>ie</>
    </ul>
</div>

有一些方法可以执行此转换或某些 CLI 工具吗? 我尝试使用 $compile 但结果不是我想要的。例如

...
var compiled = $compile('<ul><li ng-repeat="browser in browsers">{{browser}}</li></ul>');
var el = compiled($scope);
console.log(el.html())
...

结果是一个 HTML 注释

【问题讨论】:

    标签: html angularjs templates


    【解决方案1】:

    在 Chrome 中,查看页面并打开开发者工具。在元素选项卡中,右键单击&lt;html&gt;,然后单击复制为 HTML。这会复制当前屏幕上的 HTML。您还可以通过右键单击它们并选择复制为 HTML 来复制单个组件的 HTML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-22
      相关资源
      最近更新 更多