カテゴリデータは通常、本質的に反復的です。 NG-Reepeatディレクティブを使用して、テーブルを簡単に描画できます。次の例は、NG-Reepeatディレクティブを使用してテーブルを描画することを示しています。
<table> <tr> <> name </th> <th> marks </th> </tr> <tr ng-repeat = "suduent.subjects"> <td> {{subject.name}} </td> <td> {{subject.marks}}}} </td> </tr </table> </</table>テーブルは、次のように、CSSスタイルを使用してスタイルを付けることができます。
<style>テーブル、th、td {border:1px solid gray;国境崩壊:崩壊;パディング:5px;}テーブルTr:nth-child(odd){background-color:#f2f2f2;}テーブルTr:nth-child(veven){background-color:#ffffff;} </style>例
次の例では、上記のすべての指示を示します。
testangularjs.html
<html> <head> <title> Angular JSテーブル</title> <style>テーブル、th、td {border:1px solid gray;国境崩壊:崩壊;パディング:5px;}テーブルTr:nth-child(odd){background-color:#f2f2f2;}テーブルTr:nth-child(veven){background-color:#fffff.} </head> <body> <h2> angularjsサンプルアプリケーション</h2> <div ng-app = "" " ng-controller = "StudentController"> <table> <tr> <td>名の入力:</td> <td> <入力タイプ= "ng-model =" dustent.firstname "> </td> </tr> <tr <td>姓を入力:td> ng-model = "sustent.lastname"> </td> </tr> <tr> <td> name:</td> <td> {{desudent.fullname()} </td> </tr <tr <tr <td> ng-repeat = "sustent.subjects"> <td> {{subject.name}} </td> <td> {{subject.marks}} </td> </tr> </table> </tr> </table> </div> <スクリプト> $ scope = scope.student "最後の名前:「Parashar」、料金:500、件名:[{name: 'Physics'、Marks:70}、{name: 'chemistry'、marks:80}、{name: 'math'、marks:65}、{name: 'hrissh'、marks:75}、{name '、fullname:' handi '、fullname:' hindi '、full -name: StudentObject = $ scope.student; retund studentObject.firstname + "" + desudentObject.lastName; }};} </script> <script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"> </script> </body> </html>出力
WebブラウザでTextangularjs.htmlを開き、次の結果を確認してください。
上記は、AngularJSテーブルの基本的な知識の編集です。将来、関連する知識を整理し続けます。このサイトへのご支援ありがとうございます!