0

内部trにさまざまなtd コンポーネントを使用して を構築しています。

td 利用可能なコンポーネントは多数ありますが、レンダリングされるのはごく一部です。

<tr ng-repeat='row in rowlist'>
  <td ng-repeat='columnType in columnsThatShouldBeDisplayed' ng-switch='columnType'>
    <colA ng-switch-when='typeA'></colA>
    <colB ng-switch-when='typeB'></colB>
    <colC ng-switch-when='typeC'></colC>
    // and so on..
  <td>
</tr> 

これには多くのメモリが必要です。すべてのコンポーネントが構築されているように見えますが、反復ごとに 1 つしか表示されません。

これを行う正しい方法は何ですか?問題を回避し、別の方法で実行する方法に関するヒントはありますか?

4

1 に答える 1

0

repeat 要素の属性として ng-switch を含める必要があります

<div ng-controller="formPersonalInfoController">
    <form role="form">
        <div ng-repeat="Country in Countries" class="animate-switch-container" ng-switch on="Country.name">
            <div>
                <div class="animate-switch" ng-switch-when="Andorra">
                    <div class="form-group">
                        <div class="col-md-6">
                            <label class="text-info">{{ Country.name }} :</label>
                        </div>
                        <div class="col-md-6">
                            <textarea id="{{Country.Id}}" class="form-control" placeholder="{{ Country.name }}"></textarea>
                        </div>
                    </div>
                </div>
                <div class="animate-switch" ng-switch-default>
                    <div class="form-group">
                        <div class="col-md-6">
                            <label class="text-info">{{ Country.name | uppercase }} :</label>
                        </div>
                        <div class="col-md-6">
                            <input id="{{Country.Id}}" class="form-control" type="text" placeholder="{{ Country.name }}" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
</form>
</div>
于 2014-11-18T21:58:54.950 に答える