0

角度1.5を使用してプロジェクトで使用する角度データコンポーネントを作成し、データにバインドしました親スコープ内で更新されるオブジェクトの配列に(角度のある)方法で挿入されます。親スコープの値を変更すると、$ onChangesイベントが呼び出され、バインドされたデータは更新されますが、テーブルの行は、更新を反映するためにng-repeatによって変更されません。その後のデータ変更で見られる。ここに私のコードは次のとおりです。

JS:

angular.module('datatable'). 
component('datatable', { 
    bindings: { 
    graphData: '<', 
    tableId: '=', 
    divId: '=' 
    }, 
    templateUrl: 'components/graphs/datatable.template.html', 
    controller: function datatableController (DTOptionsBuilder, DTColumnBuilder) { 
     let self = this; 
     self.tableKeys = Object.keys(self.graphData[0]) 

     self.$onChanges = function() { 

      self.dtOptions = { 
       paginationType: 'full_numbers', 
       displayLength: 30, 
       dom: 'Bfrtip', 
       buttons: [ 
        {extend: 'excelHtml5'}, 
        'copy' 
       ], 
       scrollY: 450, 
       scrollX: '100%', 
       scrollCollapse: true, 
      }; 
     }; 
    } 
}) 

HTML(コンポーネント):

<datatable graph-data="$ctrl.submittedResults" table-id="'allDataTableResults'" div-id="'allDataTable'"></datatable> 

HTML(テンプレート):

<div class="col-md-10 col-md-offset-1"> 
    <div class="well well-lg" style="background: white"> 
     <div id="{{$ctrl.divId}}" style="width: 100%; height: 700px; display: block; margin: 0 auto"> 
      <table datatable="ng" dt-options="$ctrl.dtOptions" 
      class="table table-striped table-bordered" cellspacing="0"> 
       <thead> 
        <tr> 
         <th ng-repeat="key in $ctrl.tableKeys">{{key}}</th> 
        </tr> 
       </thead> 
       <tbody> 
        <tr ng-repeat="row in $ctrl.graphData"> 
         <td ng-repeat="val in row">{{val}}</td> 
        </tr> 
       </tbody> 
     </table> 
    </div> 
</div> 

私はちょうど私が持っているすべてについて試してみましたStack Overflowの関連する質問には役に立たなかったので、dtInstanceでテーブルを完全に再レンダリングすることはできませんでした。どんな助けでも大歓迎です。

+0

それは意図と実際の結果ここに提供限られたコードからも明らかではありません。コードを編集して何が起きているのかを示す[mcve]を入力すると、あなたの質問に対する回答が得られる可能性が高くなります。 – Claies

答えて

関連する問題