html - TH的AngularJS ng-repeat组

标签 html angularjs angularjs-ng-repeat

我是 AngularJS 的新程序员,在尝试为表格实现特定模板时遇到问题。 我想实现下表,但找不到如何实现:

<!DOCTYPE HTML>
    <html >
    <head>
       <title></title>
    </head>
    <body >
        <table border="1" width="50%" cellspacing="0" cellpadding="3">
        <tbody>
            <tr>
               <th colspan="33">XXXXXXXXXXXXXXXXXXXXXXX</th>
            </tr>
            <tr>
               <th rowspan="2">&nbsp;</th>
               <th colspan="2">P1</th>
               <th colspan="2">P2</th>
               <th colspan="2">P3</th>
            </tr>
            <tr >
               <th >INFO1</th>
               <th >INFO2</th>
               <th >INFO1</th>
               <th >INFO2</th>
               <th >INFO1</th>
               <th >INFO2</th>
            </tr>           
       </tbody>
       </table
    </body>
    </html>

我在 AngularJS 中有以下代码,但是我不能重复,因为没有包装的 html 元素:

    <!DOCTYPE HTML>
    <html ng-app="myApp">
    <head>
    <title></title>
        <script src="js/angular.js"></script>
        <script>
        var app = angular.module('myApp', []);
        app.controller("myCTL",['$scope',function($scope){
            $scope.datas=[{id:'1', name:'P1',pct:'10'},{id:'2', name:'P2',pct:'70'},{id:'3', name:'P3',pct:'66'}]
        }])
        </script>

    </head>
    <body ng-controller="myCTL">
        <table border="1" width="50%" cellspacing="0" cellpadding="3">
           <tbody>
              <tr>
                 <th colspan="33">XXXXXXXXXXXXXXXXXXXXXXX</th>
              </tr>
              <tr>
                 <th rowspan="2">&nbsp;</th>
                 <th colspan="2" ng-repeat="data in datas">{{data.name}}</th>
              </tr>

              <tr>

                  ng-repeat ="data in datas" [START]
                  <th >INFO1</th>
                  <th >INFO2</th>
                  ng-repeat  [END]
              </tr>         
        </tbody>
    </table

    </body>
</html>

如果有人知道如何解决这个问题,将不胜感激。 非常感谢。

最佳答案

使用ng-repeat-start and ng-repeat-end :

          <tr>
              <th ng-repeat-start ="data in datas">INFO1</th>
              <th ng-repeat-end>INFO2</th>                  
          </tr>   

关于html - TH的AngularJS ng-repeat组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26937581/

相关文章:

javascript - ng-repeat 调用 Controller 函数太多次

html - 如何在 AngularJS ng-repeat 中继器中创建独特的 `id` 属性

javascript - 将 CSS 对象转换为样式标签

javascript - jquery 无法从保存的 `visible` 中获取 `jquery object` 元素

html - 需要在不使用代码的情况下更新多个网页中的日期代码 mm/dd/yyyy

angularjs - Angular Material chalice 弹性盒布局

javascript - 内联 SVG 元素不适用于 Div

javascript - nvd3 工具提示显示索引而不是标签

javascript - 如何从 Angular 返回的服务中访问值对象?

javascript - 如果值重复,为什么 AngularJS 不想列出数组项?