我需要进行多次http调用而不订阅响应(让我们假设响应总是<div style="background:gray;">
<table style="border:0;">
<tr>
<td class="my-td-left">TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1 TD1</td>
<td class="my-td-right">TD1 TD1 TD1 TD1 TD1 TD1</td>
</tr>
<tr class="space">
<td colspan="2"></td>
</tr>
<tr>
<td class="my-td-left">TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 TD2 </td>
<td class="my-td-right">TD2 TD2 TD2 </td>
</tr>
<tr class="space">
<td colspan="2"></td>
</tr>
<tr>
<td class="my-td-left">TD3 TD3 TD3</td>
<td class="my-td-right">TD3 TD3 TD3</td>
</tr>
</table>
</div>
)。如果订阅列表为空,看起来Angular不会发出http请求。怎么逼呢?
答案 0 :(得分:5)
除非调用subscribe()
,否则可观察者是懒惰的,不做任何事情
当数据到达时,您不需要做任何事情
this.http.get(url).subscribe()
会做的。