# ngx-crud-state

> Thư viên được tạo với [Angular CLI](https://github.com/angular/angular-cli) phiên bản 10.1.3.

Latest version **0.0.16** (published 2020-10-08) · 0 weekly downloads

## Install

```sh
npm install ngx-crud-state
pnpm add ngx-crud-state
yarn add ngx-crud-state
bun add ngx-crud-state
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.16 |
| Published | 2020-10-08 |
| First published | 2020-09-28 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 384.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mannguyen |

## Links

- npm: https://www.npmjs.com/package/ngx-crud-state
- npm.io page: https://npm.io/package/ngx-crud-state

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0

## Recent versions

- 0.0.16 (latest) — 2020-10-08
- 0.0.15 — 2020-10-08
- 0.0.14 — 2020-10-08
- 0.0.13 — 2020-10-03
- 0.0.12 — 2020-10-03
- 0.0.11 — 2020-10-03
- 0.0.10 — 2020-10-03
- 0.0.9 — 2020-10-02
- 0.0.8 — 2020-10-02
- 0.0.7 — 2020-10-01
- 0.0.6 — 2020-10-01
- 0.0.5 — 2020-10-01
- 0.0.4 — 2020-09-28
- 0.0.3 — 2020-09-28
- 0.0.2 — 2020-09-28
- … 1 more at https://npm.io/package/ngx-crud-state/versions

## README

# NgxCrudState

Thư viên được tạo với [Angular CLI](https://github.com/angular/angular-cli) phiên bản 10.1.3.

Hiện nay single page application đã trở nên phổ biến và phát triển cực kì mạnh mẽ, thư viện ngx-crud-state giúp người dùng lưu trữ tất cả các trạng thái vào store. Và chỉ call api lấy data khi trên store chưa có data và ngược lại nếu store có data thì chỉ trả về dữ liệu.

## Mục lục

1. [Giới thiệu](#demo)
2. [Cài đặt](#installation)
3. [Bắt đầu](#getting-started)

## Giới thiệu

Web demo: [NgxCrudState](https://mjzzyou137.github.io/ngx-crud-state/movies)
Xem trực tiếp code trên [StackBlitz](https://stackblitz.com/github/mjzzyou137/ngx-crud-state "ngx-crud-state StackBlitz demo").

## Cài đặt

Cài đặt ngx-crud-state với npm

### NPM

```shell
npm install --save ngx-crud-state
```

## Bắt đầu

![ngx-crud-state](https://topdev.vn/blog/wp-content/uploads/2019/04/restful-api.jpg)

Khởi tạo một file metadata.ts

```typescript
import { Metadata, HttpRequestMethod } from "ngx-crud-state";

export const metadata: Metadata = {
  // https://5f4b8248ea007b0016b1d88b.mockapi.io/api/v1/users
  // RESTful API
  user: {
    entityName: "user"
  },

  // Non RESTful API
  movie: {
    entityName: "movie",
    // If the primary key is id, there is no need to declare it
    primaryKey: "maPhim",
    getItems: {
      url: `https://movie0706.cybersoft.edu.vn/api/QuanLyPhim/LayDanhSachPhim?maNhom=GP01`,
      method: HttpRequestMethod.GET
    },
    create: {},
    update: {},
    delete: {}
  },

  // No crud
  userLogin: {
    entityName: "userLogin",
    loadState: {
      url: `https://movie0706.cybersoft.edu.vn/api/QuanLyNguoiDung/DangNhap`,
      method: HttpRequestMethod.POST
    }
  }
};
```

Import `NgxCrudStateModule` vào trong root application module :

```typescript
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { CoreModule } from "./core/core.module";
import { NgxCrudStateModule } from "ngx-crud-state";
import { metadata } from './metadata

@NgModule({
  //...
  imports: [
    //...
    NgxCrudStateModule.forRoot({
        metadata: metadata,
        rootApiUrl: 'https://5f4b8248ea007b0016b1d88b.mockapi.io/api/v1'
    })
  ]
  //...
})
export class AppModule {}
```

---
_Source: https://npm.io/package/ngx-crud-state · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
