Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sabbirrahman/ng-restly
ng-restly - Resource (REST) Service for Angular 2+
https://github.com/sabbirrahman/ng-restly
angular angular2 angular4 resource rest-api
Last synced: about 1 month ago
JSON representation
ng-restly - Resource (REST) Service for Angular 2+
- Host: GitHub
- URL: https://github.com/sabbirrahman/ng-restly
- Owner: sabbirrahman
- License: mit
- Created: 2017-09-07T09:33:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-13T05:35:42.000Z (almost 7 years ago)
- Last Synced: 2024-10-04T05:07:30.499Z (about 1 month ago)
- Topics: angular, angular2, angular4, resource, rest-api
- Language: TypeScript
- Homepage:
- Size: 128 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ng-restly [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Resource%20(REST)%20service%20for%20Angular%202%20and%20beyond&url=https://github.com/sabbirrahman/ng-restly&via=sabbirrahmanme&hashtags=restapi,angular,ng)
>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](https://travis-ci.org/sabbirrahman/ng-restly.svg?branch=master)](https://travis-ci.org/sabbirrahman/ng-restly)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/sabbirrahman/ng-restly/blob/master/LICENSE)
[![NPM version](https://badge.fury.io/js/ng-restly.svg)](https://www.npmjs.com/package/ng-restly)## Installation
`npm install --save ng-restly`## How To
1. Create a service and extend it from ResourceService
```typescript
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);
}
}
```2. Inject your service wherever you would like to take the benefits of ng-restly
```typescript
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](https://github.com/sabbirrahman/ng-restly/blob/master/DOCUMENTATION.md).
## 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 [email protected]`
See full documentation for v1.0.0 [here](https://github.com/sabbirrahman/ng-restly/blob/1.0.0/DOCUMENTATION.md).
## Development & Contribution
Run `npm run test` to execute the unit tests via [Karma](https://karma-runner.github.io). This will help you to run and debug your code if you wish to contribute to the development of this library.
Enjoy 😃