簡體   English   中英

數據未在AngularJS中顯示

[英]Data doesn't show in AngularJS

首先,我要為我的英語不好而道歉:)

我想從datagrid加載模式時,AngularJS遇到問題。

這是我的網格代碼:

<tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit track by $index">
                    <td>{{data.lastName}} {{data.firstName}}</td>
                    <td>{{data.email}}</td>
                    <td>{{data.phoneNumber}}</td>
                    <td>{{data.cityID}}</td>
                    <td><button class="btn btn-primary btn-xs" ng-click="show(data.id)">DETAILS</button></td>

模態代碼:

<div class="modal-dialog">
<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title"><strong>{{row.firstName}} {{row.lastName}}</strong> Details</h4>
  </div>
  <div class="modal-body">
    <table class="table table-condensed table-hover info-table">
      <tbody>
        <tr>
          <td>Email:</td>
          <td>{{row.email}}</td>
        </tr>
     </tbody>
    </table>
  </div>
</div>

和JS代碼:

$scope.show = function (id) { 
    $http.get('inc/getDetails.php?id='+id).
    success(function(data) {
      $scope.row = data;
      $('#det-modal').modal('show');

    });

};

模態正在加載,但不加載數據。

該代碼無法正常工作,因為當在非角度環境中調用模​​式時, 變量超出范圍。

您不應直接在控制器中訪問DOM元素,因此不應在有角度的世界中使用以下行。

 $('#det-modal').modal('show');

要解決此問題,請考慮使用https://angular-ui.github.io/bootstrap/ ,這將使您能夠將行作為范圍變量傳遞。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM