如何在angularJS中的ng-Dialog模式中获取数据

时间:2015-12-23 06:14:48

标签: javascript html angularjs ng-dialog

您好我是角度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>
&#13;
&#13;
&#13;

这里是_detail_modal.html

&#13;
&#13;
<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>
&#13;
&#13;
&#13;

最后这是我的JS

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

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

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

访问数据

答案 1 :(得分: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
});