检测到断路器:拒绝时未提供配置对象:

问题描述 投票:1回答:2

检测到断路器:拒绝时未提供配置对象:当我调用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() .'}}'; 
    }

}



?>
php angularjs slim
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.