目前我有这个循环:
<tr>
<td class="description" colspan="5" >Trasaction detail here...</td>
</tr>
然后,我想在每个偶数行添加下面的代码。
i
问题是我无法在上面的循环中访问变量<table>
<tr>
<td class="branch">Branch</td>
<td class="date">Date</td>
<td class="account">Account - Account Name</td>
<td class="debit">100000</td>
<td class="credit"> </td>
</tr>
<tr>
<td class="branch">Branch</td>
<td class="date">Date</td>
<td class="account">Account - Account Name</td>
<td class="debit"> </td>
<td class="credit">100000</td>
</tr>
<tr>
<td class="description" colspan="5" >Trasaction detail here...</td>
</tr>
<tr>
<td class="branch">Branch</td>
<td class="date">Date</td>
<td class="account">Account - Account Name</td>
<td class="debit">30000</td>
<td class="credit"> </td>
</tr>
<tr>
<td class="branch">Branch</td>
<td class="date">Date</td>
<td class="account">Account - Account Name</td>
<td class="debit"> </td>
<td class="credit">30000</td>
</tr>
<tr>
<td class="description" colspan="5" >Trasaction 2 detail here...</td>
</tr>
</table>
。怎么解决这个问题?
修改 结果应该是这样的:
str = 'abcdabcd';
arr1 = str.match(/a|c/g);
arr2 = str.match(/b|d/g);
check1 = arr1.length;
console.log(arr1.length);
check2 = arr2.length;
console.log(arr2.length);
if (check1 % 2 == 0 && check2 % 2 == 0) {
console.log('both even');
}
&#13;
答案 0 :(得分:2)
这样的事情:
<table>
<ng-template ngFor let-even="even" let-odd="odd" let-n [ngForOf]="[42, 42, 43, 43, 1, 2, 3]">
<tr>
<td class="branch">Branch</td>
<td class="date">Date</td>
<td class="account">Account {{n}} - Account Name</td>
<td class="debit" *ngIf="even">100000</td>
<td class="credit" *ngIf="even"> </td>
<td class="debit" *ngIf="odd"> </td>
<td class="credit" *ngIf="odd">100000</td>
</tr>
<tr *ngIf="odd">
<td class="description" colspan="5" >Trasaction detail here...</td>
</tr>
</ng-template>
</table>