ngx-crud
Version:
CRUD services in Angular with effortless aborting, caching and observing
84 lines (62 loc) • 1.93 kB
Markdown
NGX CRUD
========
> CRUD services in Angular with effortless aborting, caching and observing.
[](https://github.com/henryruhs/ngx-crud/actions?query=workflow:ci)
[](https://coveralls.io/r/henryruhs/ngx-crud)
[](https://npmjs.com/package/ngx-crud)
[](https://npmjs.com/package/ngx-crud)
Installation
------------
```
npm install ngx-crud
```
Setup
-----
Import the `CrudModule` and `provideHttpClient` inside your `AppModule`:
```typescript
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { CrudModule } from 'ngx-crud';
@NgModule(
{
imports:
[
CrudModule
],
providers:
[
provideHttpClient(withInterceptorsFromDi())
]
})
export class AppModule
{
}
```
Usage
-----
Extend the `ExampleService` from the `CrudService`:
```typescript
import { Injectable } from '@angular/core';
import { CrudService } from 'ngx-crud';
import { RequestBody, ResponseBody } from './example.interface';
import { environment } from '@environments';
@Injectable()
@ApiUrl(environment.apiUrl)
@ApiRoute(environment.apiRoutes.example)
export class ExampleService extends CrudService<RequestBody, ResponseBody>
{
}
```
Use the HTTP operations as needed:
```typescript
exampleService.create(body, options);
exampleService.read(id, options);
exampleService.find(options);
exampleService.update(id, body, options);
exampleService.patch(id, body, options);
exampleService.delete(id, options);
exampleService.custom(method, options);
```
Documentation
-------------
Read the [documentation](https://henryruhs.gitbook.io/ngx-crud) for a deep dive.