功能特性
如果服务器端的功能定义允许,您可以使用配置状态服务在客户端获取功能值。
本文档介绍如何在Angular应用程序中获取功能值。请参阅功能特性文档了解功能系统。
使用前准备
要使用ConfigStateService,您必须将其作为依赖项注入到类中。由于该服务已在根级别提供,因此无需显式提供。
import { ConfigStateService } from '@abp/ng.core';
import { inject } from '@angular/core';
@Component({
/* 类元数据 */
})
class DemoComponent {
private config = inject(ConfigStateService);
}
如何获取特定功能
您可以使用ConfigStateService的getFeature方法从配置状态中获取特定功能。示例如下:
// this.config是ConfigStateService的实例
const defaultLang = this.config.getFeature("Identity.TwoFactor");
// 'Optional'
然后您可以检查功能值以执行相应逻辑。请注意功能键名区分大小写。
抠丁客


