From 2f578c98fab38d8a6b2ef2f128cf7581d35249a0 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 26 Oct 2020 17:05:34 +0300 Subject: [PATCH 1/3] docs: explain how to get features in Angular --- docs/en/UI/Angular/Features.md | 38 ++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/en/UI/Angular/Features.md b/docs/en/UI/Angular/Features.md index f749030a261..930fc2e527a 100644 --- a/docs/en/UI/Angular/Features.md +++ b/docs/en/UI/Angular/Features.md @@ -1,3 +1,37 @@ -# Angular UI: Features +# Features -> This document explains how to get feature values in an Angular application. See the [Features document](../../Features.md) to learn the feature system. \ No newline at end of file +You can get the value of a feature on the client-side using the [config state service](./Config-State.md) if it is allowed by the feature definition on the server-side. + +> This document explains how to get feature values in an Angular application. See the [Features document](../../Features.md) to learn the feature system. + +## Before Use + +To use the `ConfigStateService`, you must inject it in your class as a dependency. You do not have to provide the service explicitly, because it is already **provided in root**. + +```js +import { ConfigStateService } from '@abp/ng.core'; + +@Component({ + /* class metadata here */ +}) +class DemoComponent { + constructor(private config: ConfigStateService) {} +} +``` + +## How to Get a Specific Feature + +You can use the `getFeature` method of `ConfigStateService` to get a specific feature from the configuration state. Here is an example: + +```js +// this.config is instance of ConfigStateService + +const defaultLang = this.config.getFeature("Identity.TwoFactor"); +// 'Optional' +``` + +You can then check the value of the feature to perform your logic. Please note that **feature keys are case-sensitive**. + +## What's Next? + +- [Permission Management](./Permission-Management.md) From e24c05a2acec04089e5b9f5ed60a9bec3b407027 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 26 Oct 2020 17:06:09 +0300 Subject: [PATCH 2/3] docs: add navigation to Angular features doc --- docs/en/UI/Angular/Settings.md | 2 +- docs/en/docs-nav.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Settings.md b/docs/en/UI/Angular/Settings.md index 744df0a8303..f3a57758380 100644 --- a/docs/en/UI/Angular/Settings.md +++ b/docs/en/UI/Angular/Settings.md @@ -56,4 +56,4 @@ Beware though, **settings search is case-sensitive**. ## What's Next? -- [Permission Management](./Permission-Management.md) +- [Features](./Features.md) diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 56eb8d8e202..9510da38ebb 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -588,6 +588,10 @@ "text": "Settings", "path": "UI/Angular/Settings.md" }, + { + "text": "Features", + "path": "UI/Angular/Features.md" + }, { "text": "Permission Management", "path": "UI/Angular/Permission-Management.md" From 4bef91bb0f0ad463c6bce58db3453644fac9ca8a Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 26 Oct 2020 17:07:17 +0300 Subject: [PATCH 3/3] docs: remove features part from config state service --- docs/en/UI/Angular/Config-State.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/docs/en/UI/Angular/Config-State.md b/docs/en/UI/Angular/Config-State.md index d00e4639249..b1a882d43ac 100644 --- a/docs/en/UI/Angular/Config-State.md +++ b/docs/en/UI/Angular/Config-State.md @@ -93,17 +93,6 @@ const searchUrl = this.config.getApiUrl("search"); This method returns the `url` of a specific API based on the key given as its only parameter. If there is no key, `'default'` is used. -### How to Get a Specific Feature From the Store - -You can use the `getFeature` method of `ConfigStateService` to get a specific feature from the configuration state. Here is an example: - -```js -// this.config is instance of ConfigStateService - -const isChatEnabled = this.config.getFeature("Chat.Enable"); -// 'en' -``` - ### How to Get a Specific Permission From the Store You can use the `getGrantedPolicy` method of `ConfigStateService` to get a specific permission from the configuration state. For that, you should pass a policy key as parameter to the method. @@ -200,6 +189,7 @@ Please refer to `Config.Environment` type for all the properties you can pass to ## See Also - [Settings](./Settings.md) +- [Features](./Features.md) ## What's Next?