Angularjs 我无法将正确的Id发送到修改方法

Angularjs 我无法将正确的Id发送到修改方法,angularjs,asp.net-mvc,Angularjs,Asp.net Mvc,当我试图修改表中的一行时,我的代码有问题,我使用AngularJS作为客户端,ASP.Net作为rest API,这是我的API修改代码: [Route("api/Students/modifier/{id}")] public async Task<HttpResponseMessage> PUT(int id, Student value) { try { _Stude

当我试图修改表中的一行时,我的代码有问题,我使用AngularJS作为客户端,ASP.Net作为rest API,这是我的API修改代码:

[Route("api/Students/modifier/{id}")]
        public async Task<HttpResponseMessage> PUT(int id, Student value)
        {
            try
            {
                _StudentService.Update(value);
                await _unitOfWorkAsync.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
            return Request.CreateResponse(HttpStatusCode.OK);
        }
问题是delete工作正常,对于etudmodifictrl控制器,我从表中选择了正确的Id,并已将其正确发送到modal。我的问题是当我点击模式的OK按钮时,它总是显示id=1和修改前的旧数据。 例如,我选择了id为12的行,然后在模式中单击“确定”按钮,这是调试时得到的结果:

从浏览器请求详细信息


要知道问题在哪里,请从浏览器中提供您的请求详细信息请求的实际url Put请求与fiddler配合良好,但与我的codeokay不配合,那么问题在客户端。好了,字段$id是由angular设置的,用于跟踪对象,您不应该在逻辑中使用它。modifetudstore.$id可能不正确。应该是这样的modifetudstore。我对您的数据结构不太熟悉,无法回答您的问题。您正在currentPageStores中使用ng repeat=store进行迭代。商店是否有学生id?它应该是ng click=modifetudstore.id,而不是ng click=modifetudstore.$id
    <table class="table table-responsive table-hover" ng-controller="etudmodifCtrl">
<thead>
</thead>
 <tbody >
 <tr ng-repeat="store in currentPageStores>
       <td align="center">{{store.LastName}}</td>
       <td align="center">{{store.FirstName}}</td>
       <td align="center">{{store.Email}}</td> 
       <td align="center" ng-controller="etuddeleteCtrl">
          <div id="myModal" class="modal fade" role="dialog" >
            <div class="modal-dialog">
              <div class="modal-content">
                <div class="modal-header">....</div>
                <div class="modal-body">
                       <div class="form-group">
                         <label>LastName</label>
                            <div class="col-sm-10">
                 <input type="text" class="form-control"  ng-model="nomet">
                            </div>
                        </div>
                        <div class="form-group">
                         <label>FirstName</label>
                            <div class="col-sm-10">
               <input type="text" class="form-control"  ng-model="prenomet">
                            </div>
                        </div>
                        <div class="form-group">
                         <label>Email</label>
                            <div class="col-sm-10">
             <input type="text" class="form-control"  ng-model="email">
                            </div>
                        </div>
                </div>
                <div class="modal-footer">
                   <button ng-click="modifetud(store.$id)">OK</button>
                </div>
            </div>  
        </div>
     //this button opens the modal in which I will modify the data
         <button ng-click="open(store.$id)" data-target="#myModal">Modify</button>
        </td>
    </tr></tbody></table>   
    .controller("etudmodifCtrl", ["$scope", "$http", function ($scope, $http) {

     //I get the data via these method and a correct Id of the selected row
                  $scope.open = function ($id) {$http(
                    {method: 'GET', url:'http://localhost:50001/api/Students/'+$id})
                         .success(......)
                             .error 
                                   }
  $scope.modifetud = function ($id) {$http(
{method: 'PUT',url:'http://localhost:50001/api/Students/modifier/'+$id,data:'{"FirstName":"'+$scope.prenomet+'","LastName":"'+$scope.nomet+'","Email"'+$scope.email+'"}'}                                                            
       )}       
    })