32

When I take a look into Angular2 docs I can't find any REST helper module like Angular1's ngResource. I find it very useful in Angular1, so I would like to have something similar in Angular2, but the only thing I can find is 'angular2/http' which does not contain anything like that (or maybe I am not searching good enough?).

Although it is pretty much clear that it would be easy to implement a similar service on my own, is there any ready-to-use module shipped by Angular2 team or is there going to be one?

smnbbrv
  • 23,502
  • 9
  • 78
  • 109

3 Answers3

15

There are a few thirdparty libs that do this and tie in with RXjs.

Take a look at https://github.com/troyanskiy/ng2-resource-rest

Martin
  • 15,820
  • 4
  • 47
  • 56
2

js-data-angular (formerly angular-data) is well-engineered counterpart to ngResource in Angular 1.x and a wrapper for main package, js-data.

As it is shown in the examples, js-data provides framework-agnostic models and can be successfully used with Angular 2 directly.

Estus Flask
  • 206,104
  • 70
  • 425
  • 565
  • + for the answer. Is there websockets / observables support (don't see it on their website)? – smnbbrv Jun 24 '16 at 10:59
  • They are not built in. Observables [can be easily added](http://www.js-data.io/v3.0/docs/jsdata-observables). Websocket support is not provided, but can be added too (see [Angular 1.x examples from the issues](https://github.com/js-data/js-data/issues?utf8=%E2%9C%93&q=websocket)). – Estus Flask Jun 24 '16 at 12:08
2

Restangular is going to Angular2, they already have made a good job with AngularJS version. May worth the try.

[Edit] I tried it on an Angular-Seed root and it didn't integrate very well during the bundle phase. In dev mode I was easily able to send requests to the server.

The Typescript isn't really interesting since they put "any" on every object, it will need some more work to become fully production friendly.

Michael Laffargue
  • 10,116
  • 6
  • 42
  • 76