Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何在数据库中更新数据后重新加载视图页_Angularjs_Reload - Fatal编程技术网

Angularjs 如何在数据库中更新数据后重新加载视图页

Angularjs 如何在数据库中更新数据后重新加载视图页,angularjs,reload,Angularjs,Reload,我是新来的。请帮我解决这个问题。我有display.html,其中显示了记录列表,并有一个复选框来选择和更新数据库中选定的记录。一旦数据库中的记录被更新,我需要用数据库中新更新的记录刷新Display.html **Display.html:** <div data-ng-controller="SKUIntegrationCtrl"> <table class="table table-striped table-hover" width="100%"

我是新来的。请帮我解决这个问题。我有display.html,其中显示了记录列表,并有一个复选框来选择和更新数据库中选定的记录。一旦数据库中的记录被更新,我需要用数据库中新更新的记录刷新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
**Display.html:**
独一无二的
风格
{{datalist.uniqueid}
{{datalist.style}
**DisplayCtrl.js**
$scope.updateDataExtractionSAP=函数(docName,ida3a11){
skuiIntegrationService.updateDataExtractionSAP($scope,$http);
$route.reload();
警报(“重新加载”);
};
**DisplayService.js**
this.updateDataExtractionSAP=函数($scope,$http){
var skueintegrationsearchvo={};
$scope.uniquedaray=[];
angular.forEach($scope.datalist,函数(datalist){
如果(!!datalist.selected){
$scope.uniquedaray.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/updatedaetextractionsaplist',skueintegrationsearchvo);
成功(函数(数据、状态、标题、配置){
$scope.toggleloading();
var scopevalue=document.getElementById(“contentlayout”);
var controllerScope=angular.element(scopevalue.scope();
controllerScope.DataList=数据;
controllerScope.content=“SkuIntegrationSearchResult”;
$scope.showAdvPrdSearch=false;
$scope.showsearchresult=true;
警报(“在DataExtractionToSAP表中更新的选定记录”);
}).error(函数(数据、状态、标题、配置){
$scope.toggleloading();
警报(“提前文件搜索错误”);
});
};
现在我有了一个操作方法,可以将display.html中复选框中选中的记录更新到数据库中。它工作得很好。现在我需要用数据库中新更新的值重新加载display.html。请帮我做这个。我试过了
$route.reload();
它似乎不起作用

您可以通过添加函数调用来实现这一点,函数调用将获取要在另一个函数中显示的数据<代码>函数getData(){…}函数activate(){getData()}和
在控制器中添加activate()
。因此,每次在末尾添加或更新数据时,请再次调用激活函数。

难道不能再次检索数据列表吗?请帮助我编写代码片段。可能先显示完整的显示Ctrl.js