Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使用ng repeat的桌用斑马线_Html_Angularjs - Fatal编程技术网

Html 使用ng repeat的桌用斑马线

Html 使用ng repeat的桌用斑马线,html,angularjs,Html,Angularjs,我正在使用ng repeat在表中显示大量数据内容,它只包含一个元素。我试图用一种颜色显示奇数行,用另一种颜色显示偶数行。我不知道如何使用ng repeat显示单行的条纹颜色。请告诉我哪里出了问题 HTML: <thead class="rowhead"> <tr> <th class="mid">Sl.</th> <th id="tnm">Name</th> <th class="mid

我正在使用ng repeat在表中显示大量数据内容,它只包含一个
元素。我试图用一种颜色显示奇数行,用另一种颜色显示偶数行。我不知道如何使用ng repeat显示单行的条纹颜色。请告诉我哪里出了问题

HTML:

<thead class="rowhead"> 
  <tr>
    <th class="mid">Sl.</th>
    <th id="tnm">Name</th>
    <th class="mid">Age</th>
    <th class="mid">Members</th>
    <th class="mid">View-content</th>
    <th class="mid">on-going-Process</th>
  </tr>
</thead>

 <tbody ng-repeat="info in cspinfo">
   <tr class="clr">
     <td>{{$index+1}}</td>
     <td id="bnm">{{info.name}}</td>
     <td>{{info.age}}</td>
     <td>{{info.member}}</td>
     <td>{{info.View-content}}</td>
     <td>{{on-going-Process}}</td>           
   </tr>
 </tbody>

Sl。
名称
年龄
成员
查看内容
正在进行的过程
{{$index+1}}
{{info.name}
{{info.age}
{{info.member}
{{info.View content}
{{正在进行的进程}

在css中定义样式规则。然后在html中:

<tbody>
    <tr class="clr" ng-class="{style-created: $index % 2 === 0}" ng-repeat="info in cspinfo">
       <td>{{$index+1}}</td>
       <td id="bnm">{{info.name}}</td>
       <td>{{info.age}}</td>
       <td>{{info.member}}</td>
       <td>{{info.View-content}}</td>
       <td>{{on-going-Process}}</td>           
    </tr>
</tbody>

{{$index+1}}
{{info.name}
{{info.age}
{{info.member}
{{info.View content}
{{正在进行的进程}

在css中定义样式规则。然后在html中:

<tbody>
    <tr class="clr" ng-class="{style-created: $index % 2 === 0}" ng-repeat="info in cspinfo">
       <td>{{$index+1}}</td>
       <td id="bnm">{{info.name}}</td>
       <td>{{info.age}}</td>
       <td>{{info.member}}</td>
       <td>{{info.View-content}}</td>
       <td>{{on-going-Process}}</td>           
    </tr>
</tbody>

{{$index+1}}
{{info.name}
{{info.age}
{{info.member}
{{info.View content}
{{正在进行的进程}

您可以使用css中的选择器直接选择表的奇数行和偶数行,并应用所需的样式。您不必担心将类应用于使用ng repeat创建的每一行

tr:n个孩子(奇数){ 背景色:#你的颜色 }
tr:n个孩子(偶数){ 背景色:#你的颜色 }


在这里,您可以阅读有关css选择器的更多信息

您可以使用css中的选择器直接选择表中的奇数行和偶数行,并应用所需的样式。您不必担心将类应用于使用ng repeat创建的每一行

tr:n个孩子(奇数){ 背景色:#你的颜色 }
tr:n个孩子(偶数){ 背景色:#你的颜色 }


在这里,您可以阅读更多有关css选择器的信息

您所说的逻辑是正确的。但这里会发生小问题。如果我使用第n个孩子,也在改变它的颜色,你说的逻辑是正确的。但这里会发生小问题。如果我使用第n个孩子,也在改变它的颜色,你说的逻辑是正确的。但这里会发生小问题。如果我使用第n个子项,也正在更改它的颜色,您只能选择tbody标记的子项而不是表标记,或者您可以为用于管理颜色的AD添加单独的类。要仅影响此特定表的tbody中的子项,请使用
thead.rowhead+tbody tr:n个子项(奇数)
thead.rowhead+tbody tr:n子项(偶数)
用于选择器。您所说的逻辑是正确的。但这里会发生小问题。如果我使用第n个子项,也正在更改它的颜色,您只能选择tbody标记的子项而不是表标记,或者您可以为用于管理颜色的AD添加单独的类。要仅影响此特定表的tbody中的子项,请使用
thead.rowhead+tbody tr:n个子项(奇数)
thead.rowhead+tbody tr:n子项(偶数)
用于选择器。