ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
35 lines (26 loc) • 1.12 kB
Markdown
order: 90
title:
en-US: Global Configuration
zh-CN: 全局配置项
type: Dev
We add support of **global configuration** to many components. You can define the default behavior of the component through global configuration, thus reducing the code that needs to be written in the template, and support changing global config at runtime.
## How to Use?
If you want to provide default configurations to some components, you should provide an object that implements the interface **OhayoConfig** with the injection token **OHAYO_CONFIG**, in the root module (in another word, to the root injector). Like this:
```typescript
// global-config.module.ts
import { OhayoConfig, OHAYO_CONFIG } from '@ohayo/util';
const ohayoConfig: OhayoConfig = {
st: { ps: 3 },
};
@NgModule({
providers: [
{ provide: OHAYO_CONFIG, useValue: ohayoConfig },
],
})
export class GlobalConfigModule {}
```
These global configuration would be injected into a service named `OhayoConfigService` and gets stored.
## About NG-ZORRO
Please refer to NG-ZORRO Website [Documentation](https://ng.ant.design/docs/global-config/en).