Skip to content

Commit c6b0dd6

Browse files
authored
docs: updates README.md (#299)
* 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
1 parent c87785d commit c6b0dd6

File tree

1 file changed

+37
-45
lines changed

1 file changed

+37
-45
lines changed

README.md

+37-45
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,21 @@ the [ng2-cookies](https://www.npmjs.com/package/ng2-cookies) library. This servi
2222
## Installation
2323

2424
```bash
25-
npm install ngx-cookie-service --save
25+
npm i ngx-cookie-service
2626

2727
# or
2828

2929
yarn add ngx-cookie-service
3030
```
3131

32-
## Usage
33-
34-
Add the cookie service to your `app.module.ts` as a provider:
35-
36-
```typescript
37-
import {CookieService} from 'ngx-cookie-service';
38-
39-
@NgModule({
40-
...
41-
providers:[CookieService],
42-
...
43-
})
44-
45-
export class AppModule {
46-
}
47-
```
32+
## Demo
4833

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

51-
```typescript
52-
constructor(private cookieService: CookieService)
53-
{
54-
this.cookieService.set('Test', 'Hello World');
55-
this.cookieValue = this.cookieService.get('Test');
56-
}
57-
```
5836

59-
That's it!
60-
61-
### Angular 14+
37+
## Usage
6238

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

6641
```typescript
6742
import { CookieService } from 'ngx-cookie-service';
@@ -74,8 +49,8 @@ That's it!
7449
})
7550
export class HelloComponent {
7651
constructor(private cookieService: CookieService) {
77-
this.cookieService.set('Test', 'Hello World');
78-
this.cookieValue = this.cookieService.get('Test');
52+
this.cookieService.set('token', 'Hello World');
53+
console.log(this.cookieService.get('token'));
7954
}
8055
}
8156
```
@@ -95,11 +70,36 @@ That's it!
9570
cookieService = inject(CookieService);
9671

9772
constructor() {
98-
this.cookieService.set('Test', 'Hello World');
99-
this.cookieValue = this.cookieService.get('Test');
73+
this.cookieService.set('token', 'Hello World');
74+
console.log(this.cookieService.get('token'));
10075
}
10176
}
10277
```
78+
### Angular 13 or below
79+
Add the cookie service to your `app.module.ts` as a provider:
80+
81+
```typescript
82+
import {CookieService} from 'ngx-cookie-service';
83+
84+
@NgModule({
85+
...
86+
providers:[CookieService],
87+
...
88+
})
89+
90+
export class AppModule {
91+
}
92+
```
93+
94+
Then, import and inject it into a constructor:
95+
96+
```typescript
97+
constructor(private cookieService: CookieService)
98+
{
99+
this.cookieService.set('token', 'Hello World');
100+
console.log(this.cookieService.get('token'));
101+
}
102+
```
103103

104104
## Server Side Rendering
105105

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

153-
## Demo
154-
155-
https://stackblitz.com/edit/angular-ivy-1lrgdt?file=src%2Fapp%2Fapp.component.ts
156-
157153
## Supported Versions
158-
159-
`ViewEngine` support has been removed on 13.x.x. For Angular versions 13.x.x or later use the latest version of the
160-
library. For versions <=12.x.x, use 12.0.3 version
154+
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.
161155

162156
| Angular Version | Supported Version |
163-
| ---------------------- | ----------------- |
157+
|------------------------|-------------------|
158+
| 17.x.x | 17.x.x |
164159
| 16.x.x | 16.x.x |
165160
| 15.x.x | 15.x.x |
166-
| 14.x.x | 14.x.x |
167-
| 13.x.x | 13.x.x |
168-
| <=12.x.x (View Engine) | 12.0.3 |
169161

170162
# API
171163

0 commit comments

Comments
 (0)