数据编辑-模态Bootstrap

时间:2018-08-20 19:02:43

标签: angularjs

我在引导程序模式下编辑数据时遇到问题。

问题在于,在模式中,仅显示数据库中的第一条记录。

模态仅显示问题,因为它从1条记录中检索数据。

它能告诉我代码有什么问题吗,它只给我1条记录?

我的代码AngularJS:

controllersAdmin.controller('linkEdit', function( $scope, $http, $routeParams, $timeout){
    var linkID = $routeParams.id;
    $scope.id = linkID;

  $scope.link = function( link ){
    $http({
      method: 'GET',
      url: 'api/admin/links/get/' + linkID,

   }).then(function (response){

    $scope.link = response.data.records;
   },function (error){
    console.log('Blad we wczytywaniu danych');
   });
 }

   $scope.saveChanges = function( link ){
    $http({
      method: 'POST', url: 'api/admin/links/update/', data: {'link' : link}},

      ).then(function (){
        $scope.success = true;

   },function (error){
      console.log('Blad we wczytywaniu danych');

   });
   }
 });

<tr ng-repeat="link in link">
        <td>{{$index+1}}</td>
        <td><a href="{{link.links}}">{{link.links | limitTo:50}}...</a></td>

        <td>{{ link.login }}</td>
        <td>{{link.password}}</td>
        <td>{{link.date}}</td>
        <td>

          <button ng-click="deleteLink(link, $index)" class="btn btn-danger">&times;</button>

       <button data-toggle="modal" ng-click="edtlnk(link)" data-target="#edit-data" class="btn btn-primary">Edit</button>
       <div class="modal fade" id="edit-data" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
              <div class="modal-content">
                  <form method="POST" name="editlinke" role="form" ng-submit="saveChanges( link )">

                  <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                      <h4 class="modal-title" id="myModalLabel">Edit Item</h4>
                  </div>
                  <div class="modal-body">
                      <div class="container">
                          <div class="row">
                              <div class="col-xs-12 col-sm-6 col-md-6">
                                  <div class="form-group">
                                    <input type="text" class="form-control" ng-model="link.login">
                                     <input type="text" class="form-control" ng-model="link.password">
                                <input type="text" class="form-control" ng-model="link.links">
                                  </div>
                              </div>

                          </div>
                          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                          <button type="submit" class="btn btn-primary">Submit</button>
                      </div>
                  </div>
                  </form>
              </div>
          </div>
      </div>
        </td>
      </tr>

0 个答案:

没有答案