1

現在、Chrome はサイズ 40x15 のテーブルを約 6 秒でロードします。goog.editor.Table よりもはるかに遅いです。ロード時間を少なくとも 2 回短縮する必要があります。

<script type="text/ng-template" id="grid_item_renderer.html">
<span ng-switch on="cell.type">
    <textarea ng-switch-when="simple" class="cell-text-area simple-cell" ng-model="cell.data">{{cell.data}}</textarea>
    <span ng-switch-when="grid">
        <table class="declarative-grid-table" border="1" bordercolor="#CCC" cellspacing="0" tabindex="0">
            <tr ng-repeat="row in cell.data.grid" >
                <td ng-repeat="cell in row" class="declarative-grid-cell">
                    <span ng-include="'grid_item_renderer.html'"></span>
                </td>
            </tr>
        </table>
    </span>
    <span ng-switch-default>unexpected cell type</span>
</span>
</script>
<table class="declarative-grid-table" border="1" bordercolor="#CCC" cellspacing="0"  tabindex="0">
<tr ng-repeat="row in declarativeGrid" class="declarative-grid-row">
    <td ng-repeat="cell in row" class="declarative-grid-cell">
        <span ng-include="'grid_item_renderer.html'"></span>
    </td>
</tr>
</table>
4

1 に答える 1

3

Angular を使用すると、カスタム ディレクティブを作成することで、必要に応じて最適化することができます。ネストされた ng-repeat でパフォーマンスの問題が発生している場合は、テーブルの DOM 要素をプログラムで構築する独自のディレクティブを作成する時期かもしれません。カスタム ディレクティブによって作成される $watches とスコープが少なくなるため、はるかに高速でオーバーヘッドが大幅に削減されます。

于 2013-02-05T20:32:25.880 に答える