Skip to content

Commit

Permalink
docs: mention that ng14 has no standalone APIs for HttpClient to avoi…
Browse files Browse the repository at this point in the history
…d confusion
  • Loading branch information
manfredsteyer committed Nov 18, 2022
1 parent be84e3d commit 3ba7303
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ npm i angular-oauth2-oidc --save
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``:

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

import { provideHttpClient } from '@angular/common/http';
Expand All @@ -133,6 +133,26 @@ bootstrapApplication(AppComponent, {
});
```

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:

```TypeScript
// main.ts -- Angular 14 version
import { bootstrapApplication } from '@angular/platform-browser';

import { HttpClientModule } from '@angular/common/http';

import { AppComponent } from './app/app.component';
import { provideOAuthClient } from 'angular-oauth2-oidc';
import { importProvidersFrom } from '@angular/core';

bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(HttpClientModule),
provideOAuthClient()
]
});
```

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.

## Option 2: Using NgModules
Expand Down
17 changes: 16 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h2 id="sample-auth-server">Sample-Auth-Server</h2>
<h2 id="installing">Installing</h2>
<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>
<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>
<div><pre class="line-numbers"><code class="language-TypeScript">// main.ts
<div><pre class="line-numbers"><code class="language-TypeScript">// main.ts -- Angular 15+ version
import { bootstrapApplication } from &#39;&#64;angular/platform-browser&#39;;

import { provideHttpClient } from &#39;&#64;angular/common/http&#39;;
Expand All @@ -135,6 +135,21 @@ <h2 id="installing">Installing</h2>
provideHttpClient(),
provideOAuthClient()
]
});</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>
<div><pre class="line-numbers"><code class="language-TypeScript">// main.ts -- Angular 14 version
import { bootstrapApplication } from &#39;&#64;angular/platform-browser&#39;;

import { HttpClientModule } from &#39;&#64;angular/common/http&#39;;

import { AppComponent } from &#39;./app/app.component&#39;;
import { provideOAuthClient } from &#39;angular-oauth2-oidc&#39;;
import { importProvidersFrom } from &#39;&#64;angular/core&#39;;

bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(HttpClientModule),
provideOAuthClient()
]
});</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>
<h2 id="option-2-using-ngmodules">Option 2: Using NgModules</h2>
<div><pre class="line-numbers"><code class="language-TypeScript">import { HttpClientModule } from &#39;&#64;angular/common/http&#39;;
Expand Down
4 changes: 2 additions & 2 deletions docs/js/search/search_index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion projects/angular-oauth2-oidc-jwks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": {
"name": "Manfred Steyer"
},
"version": "15.0.0",
"version": "15.0.1",
"repository": "manfredsteyer/angular-oauth2-oidc",
"dependencies": {
"jsrsasign": "^10.3.0",
Expand Down
2 changes: 1 addition & 1 deletion projects/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": {
"name": "Manfred Steyer"
},
"version": "15.0.0",
"version": "15.0.1",
"repository": "manfredsteyer/angular-oauth2-oidc",
"peerDependencies": {
"@angular/common": ">=14.0.0",
Expand Down

0 comments on commit 3ba7303

Please sign in to comment.