IMHO const
in JavaScript is less than worthless. Here’s another person’s rant (warning: potentially NSFW language if curse words bother you) on the topic that makes lots of other good points. To join this team, simply open tslint.json
and change "prefer-const": true
to false
.
For format, that’s fine. I don’t understand what option1
, option2
are for, and what constitutes a single logical record. I initially assumed that a CustProfile
was a useful business object, and it had the attributes in that interface we had been discussing. Now I’m not so sure, and since you say this is “the full set of data”, then maybe this is some sort of Rosetta Stone that is decoding a bunch of numerical values. So I no longer understand really what we are looking at in human-understandable terms, so can only answer the specific queries you ask for, until I understand what the object model is supposed to look like.
in our service
export type VenueOptionMap = { [ k: string ] : string[] };
interface WiredVenueOption { option3: string; option4: string; }
fetchVenueOptions(): Observable<VenueOptionMap> {
return this.http.post<WiredVenueOption[]>(url, postbody).pipe(map(wvos => {
let rv: VenueOptionMap = {};
for (let wvo of wvos) {
if (!rv.hasOwnProperty(wvo.option3)) {
rv[wvo.option3] = [wvo.option4];
} else {
rv[wvo.option3].push(wvo.option4);
}
}
return rv;
}));
in our page
venueOptions?: VenueOptionMap;
this.service.fetchVenueOptions().subscribe(vom => this.venueOptions = vom);
Now, after that subscription resolves, venueOptions
should look like the following, given the dataset you gave me:
{
venue: [ 'hall', 'room', 'stadium', 'conference' ],
location: [ 'city' ],
capacity: [ 'test' ],
bookings: [ 'required', 'discuss' ],
manager: [ 'yes' ]
}
…so,
this.venueOptions.location
, which is [ 'city' ]
b.) what are all the ‘option4’ values where ‘option3’ = ‘venue’
this.venueOptions.venue
, which is [ 'hall', 'room', 'stadium', 'conference' ]