Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.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
Javascript Wcf REST服务删除方法在应用程序中未定义_Javascript_Angularjs_Rest_Wcf - Fatal编程技术网

Javascript Wcf REST服务删除方法在应用程序中未定义

Javascript Wcf REST服务删除方法在应用程序中未定义,javascript,angularjs,rest,wcf,Javascript,Angularjs,Rest,Wcf,我正在将wcf rest服务消费到Angular JS应用程序中。但我可以从Angular Js应用程序中删除帖子。我从localhost访问该方法,结果未找到端点。我检查了调试模式。我犯了以下错误 The creator of this fault did not specify a Reason. 我检查谷歌浏览器控制台窗口。我得到了这个结果 DELETE http://localhost:52098/HalifaxIISService.svc/DeleteCreateCurrentAcc

我正在将wcf rest服务消费到Angular JS应用程序中。但我可以从Angular Js应用程序中删除帖子。我从localhost访问该方法,结果未找到端点。我检查了调试模式。我犯了以下错误

The creator of this fault did not specify a Reason.
我检查谷歌浏览器控制台窗口。我得到了这个结果

DELETE http://localhost:52098/HalifaxIISService.svc/DeleteCreateCurrentAccount/undefined 400 (Bad Request)
这里是界面

   [OperationContract]
        [WebInvoke(Method = "DELETE",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "DeleteCreateCurrentAccount/{Id}")]
        void DeleteCreateCurrentAccount(string Id);
下面是实现

 public void DeleteCreateCurrentAccount(string Id)
        {
            try
            {
                int strId = Convert.ToInt32(Id);
                Current_Account_Details std = ctx.Current_Account_Details.Where(rec => rec.Account_Number == strId).FirstOrDefault();
                ctx.Current_Account_Details.Remove(std);
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new FaultException<string>
                        (ex.Message);
            }
        }
public void DeleteCreateCurrentAccount(字符串Id)
{
尝试
{
int strId=转换为32(Id);
当前帐户详细信息std=ctx.Current\u Account\u Details.Where(rec=>rec.Account\u Number==strId).FirstOrDefault();
ctx.活期账户详细信息。删除(标准);
ctx.SaveChanges();
}
捕获(例外情况除外)
{
抛出新的FaultException
(例如信息);
}
}
这是我的脚本代码

/// <reference path="../angular.min.js" />  



var app = angular.module("WebClientModule", [])

    .controller('Web_Client_Controller', ["$scope", 'myService', function ($scope, myService) {

        $scope.OperType = 1;
        GetAllRecords();
        //To Get All Records  
        function GetAllRecords() {
            var promiseGet = myService.getAllStudent();
            promiseGet.then(function (pl) { $scope.Users = pl.data },
                function (errorPl) {
                    $log.error('Some Error in Getting Records.', errorPl);
                });
        }
        //1 Mean New Entry  

        //To Clear all input controls.  
        function ClearModels() {
            $scope.OperType = 1;
            $scope.Account_Creation_Date = "";
            $scope.Account_Type = "";
            $scope.Branch_Sort_Code = "";
            $scope.Account_Fees = "";
            $scope.Account_Balance = "";
            $scope.Over_Draft_Limit = "";


        }


        $scope.update = function () {


            //Edit the Record
            debugger;
            User.Id = $scope.Id;
            var promisePut = myService.put($scope.Id, User)
            promisePut.then(function (p1) {
                $scope.Message = "Record is Update;"
                GetAllRecords();
                ClearModels();

            }, function (err) {
                console.log("Some Error Occured." + err);
            });
        };


        //To Get Student Detail on the Base of Student ID  
        $scope.get = function (User) {
            var promiseGetSingle = myService.get(User.Account_Number);
            promiseGetSingle.then(function (pl) {
                var res = pl.data;
                $scope.Id = res.Id;
                $scope.Account_Creation_Date = res.Account_Creation_Date;
                $scope.Account_Type = res.Account_Type;
                $scope.Branch_Sort_Code = res.Branch_Sort_Code;
                $scope.Account_Fees = res.Account_Fees;
                $scope.Account_Balance = res.Account_Balance;
                $scope.Over_Draft_Limit = res.Over_Draft_Limit;
                $scope.OperType = 0;
            },
                function (errorPl) {
                    console.log('Some Error in Getting Details', errorPl);
                });
        }
        //To Delete Record  
        $scope.delete = function (User) {
            var promiseDelete = myService.delete(User.Account_Number);
            promiseDelete.then(function (pl) {
                $scope.Message = "User Deleted Successfuly";
                GetAllRecords();
                ClearModels();
            }, function (err) {
                console.log("Some Error Occured." + err);
            });
        }

    }]);

app.service("myService", function ($http) {

    this.getAllStudent = function () {
        return $http.get("http://localhost:52098/HalifaxIISService.svc/GetCreateCurrentAccount");
    }
    //Update the Record  
    this.put = function (Id, User) {
        debugger;
        var request = $http({
            method: "put",
            url: "http://localhost:52098/HalifaxIISService.svc/UpdateCreateCurrentAccount",
            data: User
        });
        return request;
    }

    //Get Single Records  
    this.get = function (Id) {
        return $http.get("http://localhost:52098/HalifaxIISService.svc/GetCreateCurrentAccount/" + Id);
    }

    //Delete the Record  
    this.delete = function (Id) {
        var request = $http({
            method: "delete",
            url: "http://localhost:52098/HalifaxIISService.svc/DeleteCreateCurrentAccount/" + Id
        });
        return request;
    }

})
//
var app=angular.module(“WebClient模块”,[])
.controller('Web_客户端_控制器',[“$scope”,'myService',函数($scope,myService){
$scope.OperType=1;
GetAllRecords();
//获取所有记录
函数GetAllRecords(){
var promiseGet=myService.getAllStudent();
然后(函数(pl){$scope.Users=pl.data},
函数(errorPl){
$log.error('获取记录时出现一些错误',errorPl);
});
}
//1是指新条目
//清除所有输入控件。
函数ClearModels(){
$scope.OperType=1;
$scope.Account_Creation_Date=“”;
$scope.Account_Type=“”;
$scope.Branch_Sort_Code=“”;
$scope.Account_Fees=“”;
$scope.Account_Balance=“”;
$scope.Over_Draft_Limit=“”;
}
$scope.update=函数(){
//编辑记录
调试器;
User.Id=$scope.Id;
var promisePut=myService.put($scope.Id,User)
承诺书。然后(功能(p1){
$scope.Message=“记录正在更新;”
GetAllRecords();
ClearModels();
},函数(err){
log(“发生了一些错误。”+err);
});
};
//根据学生ID获取学生详细信息
$scope.get=函数(用户){
var promiseGetSingle=myService.get(User.Account\u Number);
promiseGetSingle.then(函数(pl){
var res=损益数据;
$scope.Id=res.Id;
$scope.Account\u Creation\u Date=res.Account\u Creation\u Date;
$scope.Account\u Type=res.Account\u Type;
$scope.Branch\u Sort\u Code=res.Branch\u Sort\u Code;
$scope.Account\u Fees=res.Account\u Fees;
$scope.Account\u Balance=res.Account\u Balance;
$scope.Over\u Draft\u Limit=res.Over\u Draft\u Limit;
$scope.OperType=0;
},
函数(errorPl){
log('获取详细信息时出现一些错误',errorPl);
});
}
//删除记录
$scope.delete=函数(用户){
var promiseDelete=myService.delete(用户帐号);
promiseDelete.then(功能(pl){
$scope.Message=“用户已成功删除”;
GetAllRecords();
ClearModels();
},函数(err){
log(“发生了一些错误。”+err);
});
}
}]);
app.service(“myService”,函数($http){
this.getAllStudent=函数(){
返回$http.get(“http://localhost:52098/HalifaxIISService.svc/GetCreateCurrentAccount");
}
//更新记录
this.put=函数(Id,用户){
调试器;
var请求=$http({
方法:“放”,
url:“http://localhost:52098/HalifaxIISService.svc/UpdateCreateCurrentAccount",
数据:用户
});
返回请求;
}
//获取单个记录
this.get=函数(Id){
返回$http.get(“http://localhost:52098/HalifaxIISService.svc/GetCreateCurrentAccount/“+Id);
}
//删除记录
this.delete=函数(Id){
var请求=$http({
方法:“删除”,
url:“http://localhost:52098/HalifaxIISService.svc/DeleteCreateCurrentAccount/“+Id
});
返回请求;
}
})
下面是HTML代码

@{
    Layout = null;
}

<html data-ng-app="WebClientModule">
<head title="ASAS">
    <title></title>
    <script src="~/Scripts/angular.min.js"></script>
    <script src="~/RegistrationScript/EditAccountDetails.js"></script>



</head>
<body>
    <table id="tblContainer" data-ng-controller="Web_Client_Controller">
        <tr>
            <td>
                <table style="border: solid 2px Green; padding: 5px;">
                    <tr style="height: 30px; background-color: skyblue; color: maroon;">
                        <th></th>
                        <th>Account Number</th>
                        <th>Account Creation Date</th>
                        <th>Account Type</th>
                        <th>Branch Sort Code</th>
                        <th>Account Fees</th>
                        <th>Account Balance</th>
                        <th>Over Draft Limit</th>

                        <th></th>
                        <th></th>
                    </tr>
                    <tbody data-ng-repeat="user in Users">
                        <tr>
                            <td></td>
                            <td><span>{{user.Account_Number}}</span></td>
                            <td><span>{{user.Account_Creation_Date}}</span></td>
                            <td><span>{{user.Account_Type}}</span></td>
                            <td><span>{{user.Branch_Sort_Code}}</span></td>

                            <td><span>{{user.Account_Fees}}</span></td>
                            <td><span>{{user.Account_Balance}}</span></td>
                            <td><span>{{user.Over_Draft_Limit}}</span></td>
                            <td>
                                <input type="button" id="Edit" value="Edit" data-ng-click="get(user)" />
                            </td>
                            <td>
                                <input type="button" id="Delete" value="Delete" data-ng-click="delete(user)" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>

    </table>
</body>
</html>
<script src="~/RegistrationScript/EditAccountDetails.js"></script>
@{
布局=空;
}
帐号
帐户创建日期
帐户类型
分支排序代码
账户费用
账户余额
超限吃水
{{user.Account{u Number}
{{user.Account\u Creation\u Date}
{{user.Account_Type}
{{user.Branch\u Sort\u Code}
{{user.Account_Fees}
{{user.Account_Balance}}
{{user.Over\u Draft\u Limit}}
这是我运行应用程序时的结果。

id未定义(请检查url)。什么是用户i