我想在角度2中创建一个TableRowsComponent,渲染到多个表行。
我想在这样的模板中使用它:
<table class>
<tbody>
<table-rows *ngFor="#item of list" [someInput]="item"></table-rows>
</tbody>
</table>
(因此“table-rows”将是TableRowsComponent的选择器)TableRowsComponent的模板类似于:
<tr>
<td> foo </td>
<td> bar </td>
</tr>
<tr *ngIf="something">
....
</tr>
<tr *ngFor="..">
...
</tr>
如果我们这样做,那么结果如下:
<table class>
<tbody>
<table-rows>
<tr>
...
</tr>
<tr>
...
</tr>
</table-rows>
<table-rows>
<tr>
...
</tr>
<tr>
...
</tr>
</table-rows>
</tbody>
</table>
不幸的是&lt; table-rows&gt;元素搞乱了表的呈现。如何解决这个问题呢?有没有办法使angular2不渲染&lt; table-rows&gt;元素?
答案 0 :(得分:2)
在命名选择器时,您可以使用[table-rows]
而不是table-rows
。
e.g。
`@Component({
moduleId: module.id,
selector: '[table-rows]',
templateUrl: 'table-rows.component.html'
})`
然后只需在tbody标记中使用它,ala <tbody table-rows></tbody>
答案 1 :(得分:0)
tip=raw_input("How much would you like to tip on your US$88.5 cheque, 5%, 12.5%?").rstrip("%")
cheque = 88.5
total = cheque*(float(tip)/100)+cheque
print("Thank you, the total will be total $%.2f" % (total))