Angular Modal Service如何在Angular Modal Service中传递服务功能

时间:2016-08-29 11:21:15

标签: javascript jquery angularjs

这个模态的指令代码弹出来显示。

      scope.show = function() {
                    ModalService.showModal({
                        templateUrl: "rawPopUp.html",
                        controller: function(){
                            scope.showRaw = ChartData.displayRaw;
                        }
                    }).then(function(modal) {
                        modal.element.modal();
                        modal.close.then(function(result) {
                            scope.message = "You said " + result;
                        });
                    });
                };

这是我在服务中写的服务功能。如何在我的模态服务中调用此函数以及在何处调用该函数。

.service('ChartData', function(Proxy,Links){
          var responseData = null;
  this.displayRaw = function() {
             var node = document.getElementById('dataTblId');
            /*while (node.hasChildNodes()) {
                node.removeChild(node.lastChild);
            }*/
            angular.forEach(this.responseData, function(dataArr, i) {
                var tblrow ='';             
                var dataLen=dataArr.scalarData.length;  
                var dataTableDiv = document.createElement('div');
                dataTableDiv.id = 'dataTbl0'+i;
                dataTableDiv.className = 'tbl-child1';
                document.getElementById("dataTblId").appendChild(dataTableDiv);

                var myTableDiv = document.getElementById("dataTbl0"+i); 

                var dataTableDiv1 = document.createElement('div');
                dataTableDiv1.id = 'dataTbl1'+i;
                dataTableDiv1.className = 'tbl-child1';
                document.getElementById("dataTblId").appendChild(dataTableDiv1);

                var myTableDiv1 = document.getElementById("dataTbl1"+i);
                var datatable = document.createElement('TABLE');
                var timeTable = document.createElement('TABLE');

                var dataTableBody = document.createElement('TBODY');
                var timeTableBody = document.createElement('TBODY');
                datatable.appendChild(dataTableBody);
                timeTable.appendChild(timeTableBody);
                for(var i=0;i<dataLen;i++){
                    var tr0 = document.createElement('TR');
                    dataTableBody.appendChild(tr0);
                    var td0 = document.createElement('TD');
                    td0.width='100%';
                    var dateEx = new Date(dataArr.scalarData[i][0]);
                    var dataExcel= dateEx.toUTCString("YYYY MMM dd").replace(/\s*(GMT|UTC)$/, "").substring(4);

                    td0.appendChild(document.createTextNode(dataExcel));
                    tr0.appendChild(td0);

                    var tr1 = document.createElement('TR');
                    timeTableBody.appendChild(tr1);
                    var td1 = document.createElement('TD');
                    td1.width='100%';
                    td1.appendChild(document.createTextNode(dataArr.scalarData[i][1]));
                    tr1.appendChild(td1);
                }
                myTableDiv.appendChild(datatable);
                myTableDiv1.appendChild(timeTable);                 
            });                                
            return node;
         };

所以从这里我必须在我的角度模态服务中调用this.diaplayRaw。如何调用该功能。

0 个答案:

没有答案