0

嗨,我是 Angular JS 的新手,问题是我正在通过 mysqldatabase 以 json 数组的形式获取表列表中的所有数据,但我也想在 Modal 中显示该表数据以获取详细信息:

这是我的 html,我在页面底部包含名为 _detail_modal.html 的文件

<table ng-table="table.tableParams5" class="table table-bordered table-striped table_feature">
  <tbody>
    <tr>
      <th>S.No</th>
      <th>Name</th>
      <th>Order</th>
      <th>Status</th>
      <th>SEO</th>
      <th>Action</th>
    </tr>
    <tr ng-repeat="user in $data | filter:searchText">
      <td data-title="'pkCategoryId'" >{{$index + 1}}</td>
      <td data-title="'Name'" >{{user.Name}}</td>
      <!--  <td data-title="'Order'">{{user.Order}}</td> -->
      <td>
        <select class="form-control input-sm" ng-model="rec.orders"  name="Order">
          <option ng-repeat="orders in order"  ng-selected="{{orders.Order == user.Order}}"  value="{{orders.order}}">{{orders.Order}}</option>
        </select>
      </td>
      <td data-title="'Status'">{{user.Status}}</td>
      <td><button class="btn btn-sm btn-info"  title="SEO" ng-click="seo()">  
        <em class="fa fa-search"></em>
        </button> 
      </td>
      <td>
        <button class="btn btn-sm btn-info"  title="View Category" ng-click="details()" >  
        <em class="fa fa-list"></em>
        </button>
        <!--modal start -->
        <!-- Modal end -->
        <button class="btn btn-sm btn-info" title="Edit Category" ui-sref="app.editmanage_category({id:user.pkCategoryId})" >
        <em class="fa fa-pencil"></em>
        </button>
        <button class="btn btn-sm btn-danger" title="Delete Category" ng-click="delete(user.pkCategoryId);">
        <em class="fa fa-trash"></em>
        </button>
      </td>
    </tr>
  </tbody>
</table>
</div>
</div>
<div ng-include="'app/views/_confirm_modal.html'"></div>
<div ng-include="'app/views/manage_category/_details_modal.html'"></div>
<div ng-include="'app/views/manage_category/_seo_modal.html'"></div>

这是_detail_modal.html

<script type="text/ng-template" id="modalDetailsDialogId">
  <div class="ngdialog-message"><h3> Manage Category Details</h3>
  <p> Name:{{user.Name}} </p>
  
  <button type="button" ng-click="closeThisDialog('button')" class="btn btn-default">Cancel</button>
  </div>
</script>

最后这是我的 JS

$scope.details = function() {
  ngDialog.open({
    template: 'modalDetailsDialogId',
    scope: $scope,
    className: 'ngdialog-theme-default'
  });
};

任何帮助将不胜感激。

4

2 回答 2

0

$scope.details = function() {
  ngDialog.open({
    template: 'app/views/_confirm_modal.html',
    scope: $scope,
    className: 'ngdialog-theme-default'
  });
};
您可以通过控制器包含模板,然后通过 {{user.Name}} 访问数据

于 2015-12-30T07:22:16.563 回答
0

如下调用 ngdialog.open - 非常重要的是传递数据选项。(数据:dataO)

从一个控制器:

 $scope.EditShow = function(dataO) {

        ngDialog.open({
            template: 'showDialog',
            controller: 'TopController',
            className: 'ngdialog-theme-default',
            disableAnimation: true,
            scope: $scope,
            data: dataO
        });

    }

在另一个控制器中($scope.ngDialogData 给出了在 Editshow(dataO) 中作为数据传递的所有选定值

App.controller('TopController', function ($scope, $http) {
  $scope.Detail =  $scope.ngDialogData.Description
}); 
于 2016-02-10T15:02:06.667 回答