npm

Don't miss out on this year's npm Pride t-shirt designs!Order your favorites here »

ng-restly

2.0.4 • Public • Published

ng-restly Tweet

Resource (REST) service for Angular 2+.

Did you miss the ngResource service from angular1.x in angular2+? Then you have come to the right place.

Build Status License: MIT NPM version

Installation

npm install --save ng-restly

How To

  1. Create a service and extend it from ResourceService
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ResourceService } from 'ng-restly';
 
@Injectable()
export class PostService extends ResourceService {
  constructor(protected http: HttpClient) {
    this.url = 'http://api.example.com/posts/:id';
    super(http);
  }
}
  1. Inject your service wherever you would like to take the benefits of ng-restly
import { PostService } from './post.service';
 
export class PostComponent implements OnInit {
  constructor(private postService: PostService) {}
  post: any; // Best Practice: Create and use an Interface as type (ie: PostInterface)
  ngOnInit() {
    this.postService
        .get({ id: 123 })
        .subscribe(post => this.post = post);
  }
}

Documentation

See full documentation here.

Deprecated @angular/http module Support

ng-restly v1.0.0 supports the deprecated and soon to be removed @angular/http module. If you are using version below 4.4.0 of angular you have to install v1.0.0 of ng-restly.

npm install --save ng-restly@1.0.0

See full documentation for v1.0.0 here.

Development & Contribution

Run npm run test to execute the unit tests via Karma. This will help you to run and debug your code if you wish to contribute to the development of this library.

Enjoy 😃

install

npm i ng-restly

Downloadsweekly downloads

22

version

2.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability