Skip to content

Commit 3ba7303

Browse files
committed
docs: mention that ng14 has no standalone APIs for HttpClient to avoid confusion
1 parent be84e3d commit 3ba7303

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ npm i angular-oauth2-oidc --save
117117
If you use Standalone Components introduced with Angular 14, you can use our standalone API (call to ``provideOAuthClient``) in your ``main.ts`` to setup the ``OAuthClient``:
118118

119119
```TypeScript
120-
// main.ts
120+
// main.ts -- Angular 15+ version
121121
import { bootstrapApplication } from '@angular/platform-browser';
122122

123123
import { provideHttpClient } from '@angular/common/http';
@@ -133,6 +133,26 @@ bootstrapApplication(AppComponent, {
133133
});
134134
```
135135

136+
As Angular 14 does have Standalone Components but no Standalone API for its ``HttpClient``, you need to go with the traditional ``HttpClientModule`` in this version:
137+
138+
```TypeScript
139+
// main.ts -- Angular 14 version
140+
import { bootstrapApplication } from '@angular/platform-browser';
141+
142+
import { HttpClientModule } from '@angular/common/http';
143+
144+
import { AppComponent } from './app/app.component';
145+
import { provideOAuthClient } from 'angular-oauth2-oidc';
146+
import { importProvidersFrom } from '@angular/core';
147+
148+
bootstrapApplication(AppComponent, {
149+
providers: [
150+
importProvidersFrom(HttpClientModule),
151+
provideOAuthClient()
152+
]
153+
});
154+
```
155+
136156
The ``provideOAuthClient`` function takes the same parameters as the forRoot function of the OAuthModule that is still in place for the sake of compatibility with existing code bases.
137157

138158
## Option 2: Using NgModules

docs/index.html

+16-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h2 id="sample-auth-server">Sample-Auth-Server</h2>
122122
<h2 id="installing">Installing</h2>
123123
<div><pre class="line-numbers"><code class="language-sh">npm i angular-oauth2-oidc --save</code></pre></div><h2 id="option-1-standalone-apis">Option 1: Standalone APIs</h2>
124124
<p>If you use Standalone Components introduced with Angular 14, you can use our standalone API (call to <code>provideOAuthClient</code>) in your <code>main.ts</code> to setup the <code>OAuthClient</code>:</p>
125-
<div><pre class="line-numbers"><code class="language-TypeScript">// main.ts
125+
<div><pre class="line-numbers"><code class="language-TypeScript">// main.ts -- Angular 15+ version
126126
import { bootstrapApplication } from &#39;&#64;angular/platform-browser&#39;;
127127

128128
import { provideHttpClient } from &#39;&#64;angular/common/http&#39;;
@@ -135,6 +135,21 @@ <h2 id="installing">Installing</h2>
135135
provideHttpClient(),
136136
provideOAuthClient()
137137
]
138+
});</code></pre></div><p>As Angular 14 does have Standalone Components but no Standalone API for its <code>HttpClient</code>, you need to go with the traditional <code>HttpClientModule</code> in this version:</p>
139+
<div><pre class="line-numbers"><code class="language-TypeScript">// main.ts -- Angular 14 version
140+
import { bootstrapApplication } from &#39;&#64;angular/platform-browser&#39;;
141+
142+
import { HttpClientModule } from &#39;&#64;angular/common/http&#39;;
143+
144+
import { AppComponent } from &#39;./app/app.component&#39;;
145+
import { provideOAuthClient } from &#39;angular-oauth2-oidc&#39;;
146+
import { importProvidersFrom } from &#39;&#64;angular/core&#39;;
147+
148+
bootstrapApplication(AppComponent, {
149+
providers: [
150+
importProvidersFrom(HttpClientModule),
151+
provideOAuthClient()
152+
]
138153
});</code></pre></div><p>The <code>provideOAuthClient</code> function takes the same parameters as the forRoot function of the OAuthModule that is still in place for the sake of compatibility with existing code bases.</p>
139154
<h2 id="option-2-using-ngmodules">Option 2: Using NgModules</h2>
140155
<div><pre class="line-numbers"><code class="language-TypeScript">import { HttpClientModule } from &#39;&#64;angular/common/http&#39;;

docs/js/search/search_index.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/angular-oauth2-oidc-jwks/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": {
55
"name": "Manfred Steyer"
66
},
7-
"version": "15.0.0",
7+
"version": "15.0.1",
88
"repository": "manfredsteyer/angular-oauth2-oidc",
99
"dependencies": {
1010
"jsrsasign": "^10.3.0",

projects/lib/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": {
55
"name": "Manfred Steyer"
66
},
7-
"version": "15.0.0",
7+
"version": "15.0.1",
88
"repository": "manfredsteyer/angular-oauth2-oidc",
99
"peerDependencies": {
1010
"@angular/common": ">=14.0.0",

0 commit comments

Comments
 (0)