title: Wait until my FormlyFieldConfig has finished loading
body: <p>I am running into an issue where I'm trying to use UI elements before they've completely loaded, resulting in undefined exceptions. </p>
  
  <p>The form is loaded in the components constructor, and then I call the initializeElements method to work with the UI elements. However, as I mentioned I'm getting null and undefined exceptions because I suspect the loadForms() method is not completely finished when I go to get the objects.</p>
  
  <p>I'm new to angular, so I'm not sure what I can do here to 'wait' until the form is completely loaded. I've tried placing the methods in a few different lifecycle hooks but have not had any success.</p>
  
  <p>I have my component:</p>
  
  <pre><code>export class UIComponent implements OnInit{
      form = new FormGroup({});
      model = {};
      fields: FormlyFieldConfig[];
  
      constructor(){
          this.fields = loadForm();
  
          this.initializeElements();
      };
  
      ngOnInit(){
      }; 
  
  
      initializeElements(){
          var overrides = this.form.get('Overrides'); // this is null on page load
          var firstNameObj = overrides.get('First Name'); // also null on page load
      };
  }
  </code></pre>
  
  <p>My component template:</p>
  
  <pre><code>&lt;form fxLayoutAlign="center center" [formGroup]="form"&gt;
      &lt;formly-form [form]= "form" [fields]="fields" [model]="model"&gt;&lt;/formly-form&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The method loadForms:</p>
  
  <pre><code>export function loadForms(){
      return [
                 {
                     'key': 'Overrides',
                     'fieldGroup': [{
                     'fieldGroupClassName': 'display-flex',
                     'fieldGroup': [{
                                       'key': 'First Name',
                                       'type': 'input',
                                       'value': 'New First Name',
                                       'templateOptions':{
                                            'label': 'First Name: '
                                        }
                                   },
                                       'key': 'Last Name',
                                       'type': 'input',
                                       'value': 'New Last Name',
                                       'templateOptions':{
                                            'label': 'Last Name: '
                                       }
                                   }]
                      }]
                 }
            ]
  }
  </code></pre>