我通过点击它在视图文件中更新它,并希望在视图文件中显示而不刷新它

时间:2017-07-07 06:17:42

标签: javascript angularjs ajax database cakephp-3.0

$scope.pause = function(userid){

    var id = $scope.userid;
    var status = 3;

    getClients.status(id,status).then(function(response)
    {
        console.log('Response',response);
        $scope.clients = response.data;   
        console.log('Data',$scope.clients);

        $scope.cancel();
    }); 

};

我在视图文件中通过单击更新它,并希望在视图文件中显示而不刷新它。

1 个答案:

答案 0 :(得分:0)

解,

HTML

<div ng-controller="controllerName" ng-int="getData()">

</div>

JS

    app.controller("name",fucntion(){

    $scope.getData = function(){
      //api call to get data from database
       $scope.data = resultData;
    }


    $scope.yourEditFunction = function(){
    //make API call to update data in database 
    $scope.getData();
   }

    })

但理想情况下,如果您将获取的API结果分配给$scope变量,稍后在编辑功能中更新它,则无需刷新页面角度将为您更新数据。