@@ -10,16 +10,16 @@ This content has been automatically generated from js-sdk.
1010Edits should be made here: https://github.com/open-feature/js-sdk
1111Once a repo has been updated, docs can be generated by running: yarn update :sdk-docs
1212
13- Last updated at Thu Mar 27 2025 19:59:44 GMT+0000 (Coordinated Universal Time)
13+ Last updated at Mon Apr 14 2025 08:11:07 GMT+0000 (Coordinated Universal Time)
1414-->
1515
1616<p align = " center" class = " github-badges" >
1717 <a href = " https://github.com/open-feature/spec/releases/tag/v0.8.0" >
1818 <img alt = " Specification" src = " https://img.shields.io/static/v1?label=specification&message=v0.8.0&color=yellow&style=for-the-badge" />
1919 </a >
2020
21- <a href = " https://github.com/open-feature/js-sdk/releases/tag/angular-sdk-v0.0.10 " >
22- <img alt = " Release" src = " https://img.shields.io/static/v1?label=release&message=v0.0.10 &color=blue&style=for-the-badge" />
21+ <a href = " https://github.com/open-feature/js-sdk/releases/tag/angular-sdk-v0.0.12 " >
22+ <img alt = " Release" src = " https://img.shields.io/static/v1?label=release&message=v0.0.12 &color=blue&style=for-the-badge" />
2323 </a >
2424
2525 <br />
@@ -40,21 +40,22 @@ In addition to the features provided by the [web sdk](/docs/reference/technologi
4040
4141- [ Overview] ( #overview )
4242- [ Quick start] ( #quick-start )
43- - [ Requirements] ( #requirements )
44- - [ Install] ( #install )
45- - [ npm] ( #npm )
46- - [ yarn] ( #yarn )
47- - [ Required peer dependencies] ( #required-peer-dependencies )
48- - [ Usage] ( #usage )
49- - [ Module] ( #module )
50- - [ Minimal Example] ( #minimal-example )
51- - [ How to use] ( #how-to-use )
52- - [ Boolean Feature Flag] ( #boolean-feature-flag )
53- - [ Number Feature Flag] ( #number-feature-flag )
54- - [ String Feature Flag] ( #string-feature-flag )
55- - [ Object Feature Flag] ( #object-feature-flag )
56- - [ Opting-out of automatic re-rendering] ( #opting-out-of-automatic-re-rendering )
57- - [ Consuming the evaluation details] ( #consuming-the-evaluation-details )
43+ - [ Requirements] ( #requirements )
44+ - [ Install] ( #install )
45+ - [ npm] ( #npm )
46+ - [ yarn] ( #yarn )
47+ - [ Required peer dependencies] ( #required-peer-dependencies )
48+ - [ Usage] ( #usage )
49+ - [ Module] ( #module )
50+ - [ Minimal Example] ( #minimal-example )
51+ - [ How to use] ( #how-to-use )
52+ - [ Boolean Feature Flag] ( #boolean-feature-flag )
53+ - [ Number Feature Flag] ( #number-feature-flag )
54+ - [ String Feature Flag] ( #string-feature-flag )
55+ - [ Object Feature Flag] ( #object-feature-flag )
56+ - [ Opting-out of automatic re-rendering] ( #opting-out-of-automatic-re-rendering )
57+ - [ Consuming the evaluation details] ( #consuming-the-evaluation-details )
58+ - [ Setting Evaluation Context] ( #setting-evaluation-context )
5859- [ FAQ and troubleshooting] ( #faq-and-troubleshooting )
5960- [ Resources] ( #resources )
6061
@@ -152,7 +153,7 @@ This parameter is optional, if omitted, the `thenTemplate` will always be render
152153The ` domain ` parameter is _ optional_ and will be used as domain when getting the OpenFeature provider.
153154
154155The ` updateOnConfigurationChanged ` and ` updateOnContextChanged ` parameter are _ optional_ and used to disable the
155- automatic re-rendering on flag value or context change. They are set to ` true ` by default.
156+ automatic re-rendering on flag value or contex change. They are set to ` true ` by default.
156157
157158The template referenced in ` else ` will be rendered if the evaluated feature flag is ` false ` for the ` booleanFeatureFlag `
158159directive and if the ` value ` does not match evaluated flag value for all other directives.
@@ -277,6 +278,63 @@ This can be used to just render the flag value or details without conditional re
277278</div >
278279```
279280
281+ ##### Setting evaluation context
282+
283+ To set the initial evaluation context, you can add the ` context ` parameter to the ` OpenFeatureModule ` configuration.
284+ This context can be either an object or a factory function that returns an ` EvaluationContext ` .
285+
286+ > [ !TIP]
287+ > Updating the context can be done directly via the global OpenFeature API using ` OpenFeature.setContext() `
288+
289+ Here’s how you can define and use the initial client evaluation context:
290+
291+ ###### Using a static object
292+
293+ ``` typescript
294+ import { NgModule } from ' @angular/core' ;
295+ import { CommonModule } from ' @angular/common' ;
296+ import { OpenFeatureModule } from ' @openfeature/angular-sdk' ;
297+
298+ const initialContext = {
299+ user: {
300+ id: ' user123' ,
301+ role: ' admin' ,
302+ }
303+ };
304+
305+ @NgModule ({
306+ imports: [
307+ CommonModule ,
308+ OpenFeatureModule .forRoot ({
309+ provider: yourFeatureProvider ,
310+ context: initialContext
311+ })
312+ ],
313+ })
314+ export class AppModule {}
315+ ```
316+
317+ ###### Using a factory function
318+
319+ ``` typescript
320+ import { NgModule } from ' @angular/core' ;
321+ import { CommonModule } from ' @angular/common' ;
322+ import { OpenFeatureModule , EvaluationContext } from ' @openfeature/angular-sdk' ;
323+
324+ const contextFactory = (): EvaluationContext => loadContextFromLocalStorage ();
325+
326+ @NgModule ({
327+ imports: [
328+ CommonModule ,
329+ OpenFeatureModule .forRoot ({
330+ provider: yourFeatureProvider ,
331+ context: contextFactory
332+ })
333+ ],
334+ })
335+ export class AppModule {}
336+ ```
337+
280338## FAQ and troubleshooting
281339
282340> I can import things form the ` @openfeature/angular-sdk ` , ` @openfeature/web-sdk ` , and ` @openfeature/core ` ; which should I use?
@@ -287,4 +345,4 @@ Avoid importing anything from `@openfeature/web-sdk` or `@openfeature/core`.
287345
288346## Resources
289347
290- - [ Example repo] ( https://github.com/open-feature/angular-test-app )
348+ - [ Example repo] ( https://github.com/open-feature/angular-test-app )
0 commit comments