ngx-simple-resource
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

ngx-simple-resource

Downloads Dependency Status License

logo

Alternative lib for resource services in Angular. This is parent service for any resource services, it works more like AngularJS resource and will be handy for migration from it.

Install

npm install --save ngx-simple-resource

Usage

// In app.module
import { NgxResourceModule } from 'ngx-simple-resource';

...

imports: [
  NgxResourceModule
  ...
// Service file example
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {HttpClientService} from 'ngx-simple-resource';
import {HelperService} from './helper.service';
import {Router} from "@angular/router";

@Injectable()
export class OrderService extends HttpClientService {
    url: any = 'orders';

    constructor(public http: HttpClient, public helper_service: HelperService, public router: Router) {
        super(http, router);
    }

    own(queryParams = {}) {
        return this.get(this.url + '/own', queryParams);
    }

    feedback(queryParams = {}) {
        return this.put(this.url + '/:_id/feedback', queryParams, queryParams);
    }

}
// In component
this.orderService.query('', {}).subscribe((res) => {
  this.orders = res;
})

Methods

  • create
  • show
  • update
  • remove
  • query

Contribution

Contribution is welcome.

License

MIT © Flycode LLC

Package Sidebar

Install

npm i ngx-simple-resource

Weekly Downloads

7

Version

1.0.2

License

MIT

Last publish

Collaborators

  • shekspir55
  • devgrigor