删除功能不工作angularjs


Delete function is not working angularjs

我在app.js文件中写了以下代码(这是一个rest api angularjs项目)

.controller('HomeCtrl'['$scope','Questions','$route',function($scope,Questions,$route) {
    var id = $route.id;
    Questions.get(function(data) {            
        $scope.questions = data.response;
    });
    $scope.remove = function(id) {  
        window.alert("works");
        //var id = $scope.question[id];
        // document.write(id);
        Questions.delete({id:id}).$promise.then(function(data) { 
            if(data.response){                 
               $route.reload();                 
          }                
        } , function(){
               alert("2nd");
             }
         );
     };
}])

第一个警报框和第二个警报框正在出现。但是

Questions.delete({id:id}).$promise.then(function(data) { 
    if (data.response) {                 
        $route.reload();                 
} 

不起作用。问题。delete({id:id})是"true"。但为什么不进去呢?。

这是我删除功能的其他代码。

来自模板列表.html

<a class="trash" ng-click="remove(question.id)"><span class="glyphicon glyphicon-trash"></span></a>

静止模型类

private function delete($id) {     
    $this->db->where('id',$id)->delete('questions');
    if ($this->db->affected_rows() === 1) {
        return TRUE;
    }
    return NULL;    
}

休息控制器类

public function index_delete($id)   {
    if (!$id) {
        $this->response(NULL,400);
    }
    $delete = $this->questions_model->delete($id);
    if(!is_null($delete)) {
          $this->response(array( "response" =>"deleted"),200);
    } else {
        $this->response(array("error" => "cud not save"),404);
    }   
    } 
}

有人能告诉我这里缺了什么吗?。谢谢,

出现了一个小错误。当我把私人删除改为公共删除时,它终于起作用了。