繁体   English   中英

使用angular-ui在模态窗口中生成表

[英]Generating table in modal window with angular-ui

我有带有一些按钮的web angular.js Web应用程序。 而且我需要打开模式窗口,如果用户将按下任何按钮。 在模态窗口中也有带有cols组的表,这取决于用户按下哪个按钮。 我正在尝试使用ng-repeat生成表,但是每次都没有人说空表。

我的桌子:

<table class="table">
  <th class="th" ng-repeat="col in association_cols">
    <span>{{ col.name }}</span>
  </th>
</table>

而我的控制器:

open_modal = function() {
    $http(......, function(data){
       $scope.association_cols = [{'name' : data.result.one}, {'name', data.result.two}]
    }
}

但每次我看到空的表格,没有一个th

我用以下方式打开模式窗口:

$modalInstance = $modal.open({'templateUrl' : "views/Window.tpl.html"});

谢谢。

模态将获得的作用域不是您习惯了解的常见作用域继承。 模态需求的所有内容都应通过resolve属性传递。 另外,您应该使用ModalController。

var myItem = {name: 'yeah'};

$modal.open({
   templateUrl : "views/Window.tpl.html",
   controller: MyModalController,
   resolve: {
     item: function() {return myItem},
   }
}).then(function(result) {
   //dialog was closed
});

MyModalController = function($scope, item) {
   $scope.item = item;
   console.log('MyModalController constructed and item was injected', item);
}

更新/添加:使用重写的angular-ui模式( 在0.6之前的版本中,这是$ dialogProvider),您现在需要键入如下的close / dismiss回调函数:

$modal.open({

}).result.then(function(result) {});

$http呼叫的回调不包含您填充$scope.association_cols所返回的data 它应该是:

 $http(..., function(data) {...});

您是否在传递给$modal.open()选项中定义了模态的控制器? templateUrl之后添加controller属性

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM