I'm using HttpParams that is the following constructor:
constructor(options?: {
fromString?: string | undefined;
fromObject?: {
[param: string]: string | string[];
} | undefined;
encoder?: HttpParameterCodec | undefined;
});
Can anyone explane me the meaning fromObject parameter and how to use it?
romObject?: {
[param: string]: string | string[];
} | undefined;
It's an optional parameter in the options argument of the constructor.
It means options (that's passed in the constructor) can have a fromObject property (it's not mandatory). If it's present, it must be a map where the key is a string and the value is either string or a string array (string|string[]), or it can also be undefined.
So the following are valid
const params = new HttpParams({fromObject: {bla: 'test'}});
const params = new HttpParams({fromObject: {bla: ['test1', 'test2']}});
const params = new HttpParams({fromObject: undefined});
const params = new HttpParams({});
this is not valid:
const params = new HttpParams({fromObject: 'this will fail'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With