You can also use Promise for http:

So for the service, you need to call toPromise() method:

  getVehicles(value?: string) {
return this._http.get('api/vehicles.json')
.map((response: Response) => <Vehicle[]>response.json().data)
.toPromise()
.catch(this.handleError);
}

Then in your controller, you can get the Promise back:

  getHeroes(value?: string) {
this.vehicles = this._vehicleService.getVehicles(value);
}

But notice that, we assign the Promise to the this.vehices. so it means we use 'async' pipe:

<ul>
<li *ngFor="#vehicle of vehicles | async"
(click)="select(vehicle)">
{{ vehicle.name }}
</li>
</ul>

最新文章

  1. Storm的ack机制在项目应用中的坑
  2. Spring+SpringMvc+Mybatis整合注意事项
  3. TreeMap源码分析
  4. Python基础(5)--字典
  5. 盘点十大最流行的Linux服务器发行版
  6. iOS-Block两个界面传值
  7. python的一些总结2
  8. winform 剔除空格与换行显示
  9. javascript 倒计时跳转.
  10. log4j.properties全配置 (转)
  11. ARM应用调试思路、方法总结、笔记
  12. openstack-ocata-身份验证2
  13. VS2010 集成标准com组件
  14. Sql Server语句大全
  15. c# 对JSON字符串排序(KEY/VALUE)
  16. Linux 第八天
  17. PHP报错类型
  18. 用NDK调用第三方库
  19. O&#39;Reilly总裁提姆-奥莱理:什么是Web 2.0
  20. Android判断当前网络是否可用--示例代码

热门文章

  1. mongodb的副本集总结
  2. mysql慢查优化总结
  3. 在ASP.NET中使用一般处理程序生成验证码
  4. Arcgis android - Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
  5. dom方法读取xml(不常用)
  6. 不用修改nginx的高并发合并回源架构
  7. 由浅入深完全掌握Ajax
  8. pythond对象、异常、反射的学习笔记
  9. ECSTORE 关于前台页面DIALOG的调用
  10. php的冒泡算法