ng-restly
TypeScript icon, indicating that this package has built-in type declarations

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 😃

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.4
    0
    • latest

Version History

Package Sidebar

Install

npm i ng-restly

Weekly Downloads

0

Version

2.0.4

License

MIT

Last publish

Collaborators

  • sabbirrahman