1

am new to angular. please help me in fixing the issue. I have the display.html where i have list of records displayed and having a check-box to select and update the selected record in database. once the record is updated in database i need to refresh the Display.html with the newly updated records in database

**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
3
  • can't you just retrieve datalists again? Commented Mar 24, 2016 at 4:03
  • please help me with code snippet. Commented Mar 24, 2016 at 4:31
  • probably show your full DisplayCtrl.js first Commented Mar 24, 2016 at 5:02

1 Answer 1

1

You can do that by adding your function call which are getting the data to be displayed inside another function. function getData(){...} function activate(){getData()} and add activate() in your controller. so every time you add update the data at the end call the activate function again.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.