0
檢測到殘破的攔截器:配置對象未提供拒收: 我在調用post方法時遇到此錯誤。檢測到破碎的攔截器:配置對象未提供拒收:
我已經給服務,控制器,和PHP代碼
服務
angular.module('sbAdminApp')
.factory('Branch', function($resource){
return $resource('api/branchdetails/:branch_id',{branch_id:'@_branch_id'},{
update: {
method: 'PUT'
}
});
})
.service('popupService',function($window){
this.showPopup=function(message){
return $window.confirm(message);
}
});
控制器
angular.module('sbAdminApp')
.controller('BranchDetailsController', function($scope,$state,$stateParams,$window,Branch){
$scope.branch = new Branch();
$scope.addBranch=function(){
$scope.branch.$save(function(){
$state.go('branchdetails');
});
}
});
PHP代碼
<?php
require_once('Slim/Slim.php');
require_once('dbconnection.php');
$app = new Slim();
$app->post('/branchdetails','addBranch');
$app->run();
function addBranch() {
$request = Slim::getInstance()->request();
$branch = json_decode($request->getBody());
$sql = "INSERT INTO branch(branch_name, branch_address, branch_phno, branch_mobileno, branch_contactperson, branch_createdate, branch_modifieddate) VALUES (:branch_name,:branch_address, :branch_phno, :branch_mobileno, :branch_contactperson, :branch_createdate, :branch_modifieddate)";
try {
$db = getConnection();
$stmt = $db->prepare($sql);
$stmt->bindParam("branch_name", $branch->branch_name);
$stmt->bindParam("branch_address", $branch->branch_address);
$stmt->bindParam("branch_phno", $branch->branch_phno);
$stmt->bindParam("branch_mobileno", $branch->branch_mobileno);
$stmt->bindParam("branch_contactperson", $branch->branch_contactperson);
$stmt->bindParam("branch_createdate", $branch->branch_createdate);
$stmt->bindParam("branch_modifieddate", $branch->branch_modifieddate);
$stmt->execute();
$branch->branch_id = $db->lastInsertId();
$db = null;
echo json_encode($branch);
} catch(PDOException $e) {
echo '{"error":{"text":'. $e->getMessage() .'}}';
}
}
?>
我是新來angularjs,所以請幫我指出,我需要保持這種攔截器? –
即使我得到了另一個這樣的錯誤「SyntaxError:意外的令牌S 在Object.parse(本機)」 –
我沒有說攔截攔截器,我說找到它,搜索所有角度的文件'$ httpProvider'和看看我什麼時候用過? – Exlord