-
Notifications
You must be signed in to change notification settings - Fork 122
Decorators
Michael Dostál edited this page Nov 14, 2018
·
3 revisions
-
Attribute(options: AttributeDecoratorOptions)
-
AttributeDecoratorOptions
:-
converter
, optional, must implementPropertyConverter
interface -
serializedName
, optional
-
-
-
NestedAttribute(options: AttributeDecoratorOptions)
-
Nested Attributes can be user for complex attributes:
- Array of simple typed values
[1,2,3]
- Array of complex values
[{firstName:'Peter',...},...]
- Complex object
{firstName:'John', lastName:'Hancock',...}
- Array of simple typed values
-
AttributeDecoratorOptions
:-
converter
, optional, must implementPropertyConverter
interface -
serializedName
, optional
-
-
NOTE: when using NestedAttribute you always need to specify
JsonModelConverter
- Example:
-
//Array of simple typed values (string, number....)
@NestedAttribute({converter: new JsonModelConverter(Array,{hasMany:true})}
emails: Array<string>;
//Array of complex values
@NestedAttribute({converter: new JsonModelConverter(Item,{hasMany:true})}
items: Array<Item>;
//Complex value
@NestedAttribute({converter: new JsonModelConverter(Item)}
item: Item;
BelongsTo()
HasMany()
-
JsonAttribute(options: AttributeDecoratorOptions)
-
AttributeDecoratorOptions
:-
converter
, optional, must implementPropertyConverter
interface -
serializedName
, optional
-
-