Angular:全局功能API
ConfigStateService.getGlobalFeatures API允许您在客户端获取全局功能的启用状态。
本文档仅说明JavaScript API。请参阅全局功能文档以了解ABP全局功能系统。
使用方法
import { ConfigStateService } from '@abp/ng.core';
import { Component, OnInit, inject } from '@angular/core';
@Component({
/* 此处为类的元数据 */
})
class DemoComponent implements OnInit {
private config = inject(ConfigStateService);
ngOnInit(): void {
// 获取所有已启用的全局功能
const getGlobalFeatures = this.config.getGlobalFeatures();
// 示例结果:`{ enabledFeatures: [ 'Shopping.Payment', 'Ecommerce.Subscription' ] }`
// 或者使用可观察对象方式
this.config.getGlobalFeatures$().subscribe(getGlobalFeatures => {
// 在此处使用getGlobalFeatures
})
// 检查特定全局功能是否启用
this.config.getGlobalFeatureIsEnabled('Ecommerce.Subscription')
// 示例结果为 `true`
this.config.getGlobalFeatureIsEnabled('My.Subscription')
// 示例结果为 `false`
// 或者使用可观察对象方式
this.config.getGlobalFeatureIsEnabled$('Ecommerce.Subscription').subscribe((isEnabled:boolean) => {
// 在此处使用isEnabled
})
}
}
抠丁客


