Skip to content

Commit

Permalink
docs: updates README.md (#299)
Browse files Browse the repository at this point in the history
* build(ci): enable tests step in GitHub Actions CI workflow

* build(ci): enable tests step in GitHub Actions CI workflow

* build(ci): enable tests step in GitHub Actions CI workflow

* docs: updates README.md

* build(ci): Switch pnpm with npm due to issue with TS and SSR

This commit replaces `pnpm` with `npm` in the Github Actions workflows.

* build(ci): Switch pnpm with npm due to issue with TS and SSR

This commit replaces `pnpm` with `npm` in the Github Actions workflows.

* build(ci): Switch pnpm with npm due to issue with TS and SSR

This commit replaces `pnpm` with `npm` in the Github Actions workflows.

* feat(core): bump version to 17.0.1

* docs: updates README.md

* docs: updates README.md
  • Loading branch information
pavankjadda authored Jan 6, 2024
1 parent c87785d commit c6b0dd6
Showing 1 changed file with 37 additions and 45 deletions.
82 changes: 37 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,21 @@ the [ng2-cookies](https://www.npmjs.com/package/ng2-cookies) library. This servi
## Installation

```bash
npm install ngx-cookie-service --save
npm i ngx-cookie-service

# or

yarn add ngx-cookie-service
```

## Usage

Add the cookie service to your `app.module.ts` as a provider:

```typescript
import {CookieService} from 'ngx-cookie-service';

@NgModule({
...
providers:[CookieService],
...
})

export class AppModule {
}
```
## Demo

Then, import and inject it into a constructor:
https://stackblitz.com/~/github.com/pavankjadda/ngx-cookie-service-demo

```typescript
constructor(private cookieService: CookieService)
{
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
}
```

That's it!

### Angular 14+
## Usage

1. Angular 14 introduced support for standalone components.
If you are using just standalone components, you can import the service directly into the component
1. In standalone components, import the CookieService directly into the component

```typescript
import { CookieService } from 'ngx-cookie-service';
Expand All @@ -74,8 +49,8 @@ That's it!
})
export class HelloComponent {
constructor(private cookieService: CookieService) {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
this.cookieService.set('token', 'Hello World');
console.log(this.cookieService.get('token'));
}
}
```
Expand All @@ -95,11 +70,36 @@ That's it!
cookieService = inject(CookieService);

constructor() {
this.cookieService.set('Test', 'Hello World');
this.cookieValue = this.cookieService.get('Test');
this.cookieService.set('token', 'Hello World');
console.log(this.cookieService.get('token'));
}
}
```
### Angular 13 or below
Add the cookie service to your `app.module.ts` as a provider:

```typescript
import {CookieService} from 'ngx-cookie-service';

@NgModule({
...
providers:[CookieService],
...
})

export class AppModule {
}
```

Then, import and inject it into a constructor:

```typescript
constructor(private cookieService: CookieService)
{
this.cookieService.set('token', 'Hello World');
console.log(this.cookieService.get('token'));
}
```

## Server Side Rendering

Expand Down Expand Up @@ -150,22 +150,14 @@ server.get('*', (req, res) => {
cookies in SSR. Then proceed to use `ngx-cookie-service` as usual.
4. See the [sample repo](https://github.com/pavankjadda/angular-ssr-docker) for more details.

## Demo

https://stackblitz.com/edit/angular-ivy-1lrgdt?file=src%2Fapp%2Fapp.component.ts

## Supported Versions

`ViewEngine` support has been removed on 13.x.x. For Angular versions 13.x.x or later use the latest version of the
library. For versions <=12.x.x, use 12.0.3 version
We follow angular [LTS versions](https://angular.dev/reference/versions#actively-supported-versions). The latest version of the library supports Angular 17.x.x. Angular 14.x.x or below is not supported.

| Angular Version | Supported Version |
| ---------------------- | ----------------- |
|------------------------|-------------------|
| 17.x.x | 17.x.x |
| 16.x.x | 16.x.x |
| 15.x.x | 15.x.x |
| 14.x.x | 14.x.x |
| 13.x.x | 13.x.x |
| <=12.x.x (View Engine) | 12.0.3 |

# API

Expand Down

0 comments on commit c6b0dd6

Please sign in to comment.