title: Getting Error: Uncaught (in promise): TypeError: Cannot read property 'value' of null when I implement ngAfterViewInit
body: <p>I'm trying to show a Google Map which gets the place_id from an html value.</p>
  <p><strong>activity-details.page.html</strong></p>
  <pre><code>                    &lt;ion-col&gt;
                          &lt;div id=&quot;map&quot;&gt;&lt;/div&gt;
                          &lt;div *ngIf=&quot;activities&quot;&gt;
                          &lt;input type=&quot;hidden&quot; id=&quot;place_id&quot; value=&quot;{{ activities.place_id }}&quot; /&gt;
                          &lt;/div&gt;
                      &lt;/ion-col&gt;
                  &lt;/ion-row&gt;
  </code></pre>
  <p>This is the code returned in the browser.</p>
  <pre><code>&lt;input _ngcontent-irr-c150=&quot;&quot; type=&quot;hidden&quot; id=&quot;place_id&quot; value=&quot;ChIJ21P2rgUrTI8Ris1fYjy3Ms4&quot;&gt;
  </code></pre>
  <p>I'm trying to set the map options as the last thing after all the code has loaded.</p>
  <p><strong>activity-details.page.ts</strong></p>
  <pre><code>    ngAfterViewInit() {
      this.geocodePlaceId(
        this.geocoder = new google.maps.Geocoder(),
        this.map = new google.maps.Map(
          document.getElementById(&quot;map&quot;) as HTMLElement,
          {
            zoom: 8,
          }
        ),
        this.infowindow = new google.maps.InfoWindow());
    }
  </code></pre>
  <p>The issue starts when get I the place_id value from the HTML in this last function.</p>
  <p><strong>activity-details.page.ts</strong></p>
  <pre><code>geocodePlaceId(
      geocoder: google.maps.Geocoder,
      map: google.maps.Map,
      infowindow: google.maps.InfoWindow
    ) {
      const placeId = (document.getElementById(&quot;place_id&quot;) as HTMLInputElement).value;
      geocoder.geocode({ placeId: placeId }, (results, status) =&gt; {
        ...//the rest of the options set up for the map
    }
  </code></pre>
  <p>I keep getting. ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'value' of null
  TypeError: Cannot read property 'value' of null</p>
  <p>What am I doing wrong?</p>