ngDialog不会在Template中打开html页面

时间:2017-05-16 15:31:21

标签: javascript angularjs

(function(){
var app = angular.module('sbi', ['ui.grid', 'ngDialog']);

var cmbStati = {};

app.config(['ngDialogProvider', function (ngDialogProvider) {
    ngDialogProvider.setDefaults({
        className: 'ngdialog-theme-default',
        plain: false,
        showClose: true,
        closeByDocument: false,
        closeByEscape: false,
        appendTo: false,
        preCloseCallback: function () {
            console.log('default pre-close callback');
        }
    });
}]);

    app.controller('PanelController',                         ['$scope',  '$compile', 'uiGridConstants', 'ngDialog', function ($scope,  $compile, uiGridConstants, ngDialog){

    var actionTemplate = '<div class="ui-grid-cell-contents"><img class="addNotes" src="images/button/detail.gif" ng-click="grid.appScope.dettaglio(row, false)" /></div>';

    $scope.dettaglio = function(row){

        ngDialog.open({
            template: 'dialog_sbi.html',
            scope: $scope,
            className: 'ngdialog-theme-default', 
            height: 400, 
            plain: true 
        });
     };

    $scope.highlightFilteredHeader = function( row, rowRenderIndex, col, colRenderIndex ) {
            if( col.filters[0].term ){
              return 'header-filtered';
            } else {
              return '';
            }
          };





    $scope.gridOptions =  {
            enableFiltering: true,

            onRegisterApi: function(gridApi){
              $scope.gridApi = gridApi;
            },
            columnDefs: [

              { field: 'azioni', enableFiltering: false, width: 85, enableSorting: false, enableColumnMenu: false, cellTemplate: actionTemplate, displayName: 'Azioni'},
              { field: 'codeSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
              { field: 'nomeSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
              { field: 'cognSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
              { field: 'codeFiscaleSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
              { field: 'descStato' , headerCellClass: $scope.highlightFilteredHeader }
            ]
          };

    //    $scope.listaOptions = cmbStati;
     $scope.toggleFiltering = function(){
            $scope.gridOptions.enableFiltering = !$scope.gridOptions.enableFiltering;
            $scope.gridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
          };

          $scope.filteredRows=[];

    var data = {};

    console.log("search");
    var loadUrl = "/sky_visp/subinstaller/inserimento/dettaglio.do?methodName=doSearchNg";

    $.ajax({
        async: false,
        url : loadUrl,
        type: "POST",
        data: data, 
        dataType: 'json',
        cache: false,
        complete: function(){
            console.log("Nice search");
        },
        success : function (ritornoSearch, stato) {
            console.log("Made it search");
            console.log("ritornoSearch: "+ritornoSearch);
            $scope.gridOptions.data = ritornoSearch;
        },
        error : function (richiesta, stato, errori) {
            console.log("Nope search");
        }
    });  

       }]); 

    })();

当我在ngDialog.open中调用模板时,对话框实际显示,但它打印的是html页面的名称。 如何正确打开HTML? 我真的不明白我错过了什么。

我尝试了整个路径,用“”调用它,删除了''

我真的不明白。

1 个答案:

答案 0 :(得分:0)

如果您参考html文件,则需要使用 templateUrl 而不是模板

试试这个:

ngDialog.open({
        templateUrl: 'dialog_sbi.html',
        scope: $scope,
        className: 'ngdialog-theme-default', 
        height: 400, 
        plain: true 
    });
 };