2016-03-24 33 views
0

是新增角度。請幫我解決這個問題。我有display.html我有顯示記錄列表,並有一個複選框來選擇和更新數據庫中選定的記錄。一旦記錄在數據庫中更新,我需要在數據庫如何在角度更新數據庫中的數據後重新加載查看頁面

**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

難道你不能再檢索datalists? – sdfacre

+0

請幫我用代碼片段。 –

+0

可能首先顯示您的完整DisplayCtrl.js – sdfacre

回答

0

你可以通過添加你的函數調用它越來越另一個函數中要顯示的數據與最新更新的記錄刷新Display.html。您的控制器中的function getData(){...} function activate(){getData()}add activate()。所以每次添加更新時,數據最後都會再次調用activate函數。

相關問題