Decorator
ValueModule | import { Value } from "@tsed/common" |
---|---|
Source | /packages/common/src/config/decorators/value.ts |
Overview
function Value(expression: any, defaultValue?: any): (target: any, propertyKey: string) =>; void;
Description
Return value from ServerSettingsService.
Example
import {Env} from "@tsed/core";
import {Constant, Value} from "@tsed/common";
export class MyClass {
@Constant("env")
env: Env;
@Value("swagger.path")
swaggerPath: string;
@Value("swagger.path", "defaultValue")
swaggerPath: string;
constructor() {
console.log(this.swaggerPath) // undefined. Not available on constructor
}
$onInit() {
console.log(this.swaggerPath) // something
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22