2016-08-25 10 views
0

ngDialogでは、ボタンクリックで合計を表示するためにUIグリッドが使用されます。アンギュラuiグリッドはngDialogでは機能しません

​​

特殊性(コンテキスト)以下のコードの2である:一部のHTMLノードは角度指令通常の作業にコンパイルして、動的ウェブページに注入され、これはChrome拡張機能であるれている。その結果、エラーが参照ngDialogの影響について

function totalsButtons($scope, $http, $document, $element, $compile, ngDialog, uiGridConstants) { 
    //First insert button right of "Close" hyperlink 
    var elements_arr = document.getElementsByTagName("span"); 
    var close_el = null; 
    //Looking for target link "Close" 
    for (var element in elements_arr) { 
    if(elements_arr[element].innerHTML == "Закрыть") { 
     close_el = elements_arr[element]; 
     break; 
    } 
    } 

    //Define parent node where insert new button to 
    $scope.totals_butns_line = close_el.parentNode.parentNode; 

    //Define table (uses ui-grid) 
    $scope.totalsByMonthG = {}; 
    $scope.totalsByMonthG.columnDefs = [ 
     { name: 'year', displayName:'Year'}, 
     { name: 'month', displayName:'Month'}, 
     { name: 'totals_agency', displayName:'Totals Agency (VAT)'}, 
     { name: 'totals_client', displayName:'Totals Client (VAT)'}, 
    ]; 
    $scope.totalsByMonthG.data = [{"year":"2016", "month":"10", "totals_agency":"10", "totals_client":"20"}]; 
    $scope.totalsByMonthG.onRegisterApi = function(gridApi){ 
     //set gridApi on scope 
     $scope.gridApi = gridApi; 
    }; 

    //Define and insert a button "Tools by months" into html dynamically 
    var elem = document.createElement('a'); 
    elem.setAttribute("href", "#"); 
    elem.setAttribute("class", "dyn"); 
    elem.setAttribute("ng-click", "openTotalsByMonth()"); 
    var html_code = '<span>Totals by months</span>' + "\n"; 
    elem.innerHTML = html_code; 
    $scope.totals_butns_line.appendChild(elem); 
    $compile(elem)($scope); 


    //Define and insert template of dialog "Totals by months" (uses ngDialog) 
    var dialog = document.createElement('script'); 
    dialog.setAttribute("id", "openTotalsByMonth"); 
    dialog.setAttribute("type", "text/ng-template"); 
    html_code = ""; 
    html_code += '<div class="ngdialog-message">'; 
    html_code += '<h2>Totals by months</h2>'; 
    html_code += '<div ui-grid="totalsByMonthG" class="grid"></div>'; 
    html_code += '</div>'; 
    html_code += '<div class="ngdialog-buttons mt">'; 
    html_code += '<input type="button" value="OK" ng-click="closeThisDialog()"/>'; 
    html_code += '</div>'; 
    dialog.innerHTML = html_code; 
    $scope.totals_butns_line.appendChild(dialog); 
    $compile(dialog)($scope); 


    $scope.openTotalsByMonth = function() { 
    //The function activates by ngClick in button "Totals by months" 

    //Open a dialog 
    ngDialog.open({ 
     template: 'openTotalsByMonth' 
    }); 
    }; 
    //Error here 

} 

私の仮説が証明されています。私は他のブロック(ないngDialog)に

<div ui-grid="totalsByMonthG" class="grid"></div> 

を挿入した場合 - 表が示されています。

答えて

0

私の同僚に感謝します。問題は、ngDialog.openブロックを次のように置き換えて解決しました。

//Open a dialog 
ngDialog.open({ 
    template: 'openTotalsByMonth', 
    scope: $scope 
}); 
関連する問題