I have an Observable which pulls some data from a Webservice and returns a Array of Objects back which looks like this.
The observable is created like this
contactFields$: Observable<IServerDropdownOption[]>;
this.contactFields$ = this.mailTemplateService.templateLookup(this.guids.MAIL_TEMPLATE_CONTACT_FIELDS);
Which returns something like this
[
     {value: "{{ first_name | fallback: "" }}", name: "First Name", selected: undefined},
     {value: "{{ last_name | fallback: "" }}", name: "Last Name", selected: undefined}
]
I need to be able to transform this Array of object into a object which will at the end look like this.
{
 "{{ first_name | fallback: "" }}" : "First Name",
 "{{ last_name | fallback: "" }}" : "Last Name"
}
Revised ngOnInit() Code
  ngOnInit() {
    this.contactFields$ = this.mailTemplateService.templateLookup(this.guids.MAIL_TEMPLATE_CONTACT_FIELDS);
    this.contactFields$.subscribe(res => console.log(res));
    this.transformArr();
    this.initForm();
    // Custom button
    FroalaEditor.DefineIcon('my_dropdown', {NAME: 'cog', SVG_KEY: 'cogs'});
    FroalaEditor.RegisterCommand('my_dropdown', {
    title: 'User Fields',
    type: 'dropdown',
    focus: false,
    undo: false,
    refreshAfterCallback: true,
    options: this.result,
    callback(cmd, val) {
        console.log (val);
    },
    // Callback on refresh.
    refresh($btn) {
        console.log ('do refresh');
    },
    // Callback on dropdown show.
    refreshOnShow($btn, $dropdown) {
        console.log ('do refresh when show');
    }
    });
TransformArray Code
transformArr() {
    console.log('Calling Transform');
    this.contactFields$.subscribe(res => {
    this.result = new Object() as { [key: string]: string; };
    for (const each of res) {
        console.log('Looping');
        this.result[each.value] = each.name;
        console.log(this.result);
  }
});
 }
IServerDropdownOptioncode?