簡體   English   中英

如何在ng-repeat中水平添加數據

[英]how to add data horizontally in ng-repeat

如何水平添加按鈕,如下圖所示,請幫助我,我想在一列中動態添加主題按鈕,如何在angularjs中水平添加

 <table class="table table-bordered table-striped table-hover table-condensed mb-none dataTable no-footer" role="grid">
                    <thead>
                        <tr>
                            <th style="width: 120px;" colspan="1" rowspan="1">Days</th>
                            <th style="width: 760px;" colspan="1" rowspan="1">Schedules</th>
                            <th style="width: 100px;" colspan="1" rowspan="1">Add</th>

                        </tr>
                    </thead>
                    <tbody class="gradeX">
                        <tr ng-repeat="x in additems">
                            <td>{{x.teacher_name }}</td>
                            <td><div class="btn-group" role="group">
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Math
</button>
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
    <a class="dropdown-item" href="#">Dropdown link</a>
    <a class="dropdown-item" href="#">Dropdown link</a>
</div>

                            <td><a href="" data-toggle="tooltip" title="Remove Subject" ng-click="removesubject(x)"><i class="fa fa-close text-danger" aria-hidden="true"></i></a></td>


                        </tr>
                    </tbody>
                </table>

我想要下面這樣的圖像 在此處輸入圖片說明

這里介紹了基本邏輯:

 angular.module('app',[]).controller('MyController', function($scope){ $scope.items=[ {name:'Sunday', stuff:[]}, {name:'Monday', stuff:[]} ]; $scope.add = function(stuff){ stuff.push(stuff.length); }; }) 
 table, th, td { border: 1px solid black; border-collapse: collapse; } 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app='app' ng-controller='MyController'> <table> <tr> <th>Day</th> <th>Schedule</th> <th></th> </tr> <tr ng-repeat='item in items'> <td>{{item.name}}</td> <td> <span ng-repeat='sub in item.stuff'>{{sub}}{{$last ? '' : ','}}</span> </td> <td> <input type='button' value='Add' ng-click='add(item.stuff)'/> </td> </tr> </table> </div> 

暫無
暫無

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

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