Sunday, May 01, 2016

Angular 2 HTTP JSON Service

Live Demo
Github Repo

Here is a bare minimum demo of how to use Angular 2 HTTP JSON Service:https://github.com/huguogang/ng2tsdemo/blob/master/json_service.html

The demo uses observable instead of promise. A few potential catches:
  • Import Rx.js in html file:
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    
  • Import rxjs/Rx in service:
    import 'rxjs/Rx'
  • Register HTTP_PROVIDERS

No comments: