2016-03-24 8 views
0

neu zu eckig. Bitte helfen Sie mir, das Problem zu beheben. Ich habe die display.html, wo ich eine Liste von Datensätzen angezeigt habe und ein Kontrollkästchen zur Auswahl und Aktualisierung des ausgewählten Datensatzes in der Datenbank habe. wenn der Datensatz in der Datenbank aktualisiert wird, ich brauche die Display.html mit den neu aktualisierten Datensätze in der DatenbankSo laden Sie die Ansichtsseite nach dem Aktualisieren der Daten in der Datenbank im Winkel

**Display.html:** 

    <div data-ng-controller="SKUIntegrationCtrl"> 

    <table class="table table-striped table-hover" width="100%" 
     style="overflow-x: scroll;"> 
     <tr> 
      <th><input type="checkbox" ng-model="selectedAll" 
       ng-click="checkAll()" /></th> 
      <th class="imagetableth"><b>UniqueID</b></th> 
      <th class="imagetableth"><b>Style</b></th> 
     </tr> 
     <tr 
      ng-repeat="datalist in datalists| pagination: curPage * pageSize | limitTo: pageSize"> 
      <td><input type="checkbox" ng-model="datalist.selected" 
       value="datalist.uniqueid"> </input></td> 
      <td class="val"><span class="glyphicon sort-icon">    {{datalist.uniqueid}} 
      </span></td> 
      <td class="val"><span class="glyphicon sort-icon">{{datalist.style}} 
      </span></td> 
     </tr> 
    </table> 
    <input type="button" name="Search" value="" 
     ng-disabled="authenticatedUser" ng-click="updateDataExtractionSAP()" 
     ng-class="enableDisableButton" /> 
     </div> 

**DisplayCtrl.js** 

    $scope.updateDataExtractionSAP = function (docName,ida3a11) { 
     SKUIntegrationService.updateDataExtractionSAP($scope, $http); 
     $route.reload(); 
     alert("Reload"); 
    }; 

**DisplayService.js** 

     this.updateDataExtractionSAP = function ($scope, $http) { 
     var SkuIntegrationSearchVo = {}; 

       $scope.uniqueIDArray = []; 
       angular.forEach($scope.datalists, function(datalist){ 
       if (!!datalist.selected){ 
        $scope.uniqueIDArray.push(datalist.uniqueid); 
       } 
       }) 

     SkuIntegrationSearchVo.uniqueIDList = $scope.uniqueIDArray; 
     var scopevalue = document.getElementById("contentlayout"); 
     var controllerScope = angular.element(scopevalue).scope(); 
     controllerScope.documentcriteriadata = SkuIntegrationSearchVo; 


     $scope.toggleloading(); 
     var promise = $http.post('/PMDBViewer/userlogin/LandingLayout/updateDataExtractionSAPList', SkuIntegrationSearchVo); 
     promise.success(function (data, status, headers, config) { 
      $scope.toggleloading(); 
      var scopevalue = document.getElementById("contentlayout"); 
      var controllerScope = angular.element(scopevalue).scope(); 
      controllerScope.datalists = data; 
      controllerScope.content = "SkuIntegrationSearchResult"; 
      $scope.showAdvPrdSearch = false; 
      $scope.showsearchresult = true; 
      alert("Selected records updated in DataExtractionToSAP table"); 
     }).error(function (data, status, headers, config) { 
      $scope.toggleloading(); 
      alert("error in advance Document Search"); 
     }); 
    }; 


Now i have an action method to update the records selected in check box in display.html to the database. It is working fine. Now i need to re-load the display.html with the newly update values in database. Please help me on this. i tried 

    $route.reload(); 

it seems not working 
+0

können Sie nicht einfach wieder Datenlisten abrufen? – sdfacre

+0

bitte helfen Sie mir mit Code-Snippet. –

+0

zeigen Sie wahrscheinlich zuerst Ihre volle DisplayCtrl.js an – sdfacre

Antwort

0

Sie aktualisieren können, indem Sie Ihren Funktionsaufruf, der die Daten werden immer in einer anderen Funktion angezeigt werden tun. function getData(){...} function activate(){getData()} und add activate() in Ihrem Controller. Jedes Mal, wenn Sie die Daten am Ende aktualisieren, rufen Sie die Aktivierungsfunktion erneut auf.