title: Datalayer.push with Typescript in Angular 6
body: <p>When I click on button, I should send into datalayer information, but I don't know how to do it, because I'm using Angular 6, so I need to use Typescript and window.dataLayer.push not working and give me this error</p>
  
  <p><a href="https://i.stack.imgur.com/bnrhl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bnrhl.png" alt="enter image description here"></a></p>
  
  <p>Form</p>
  
  <pre><code>&lt;form&gt;
              &lt;div class="radio"&gt;
                &lt;input value="Yes" id="radio-1" [(ngModel)]="answer" name="radio" type="radio"&gt;
                &lt;label class="radio-label rob-l" for="radio-1"&gt;Yes&lt;/label&gt;  
            &lt;/div&gt;
            &lt;div class="radio"&gt;
              &lt;input value="No" id="radio-2" [(ngModel)]="answer" name="radio" type="radio"&gt;
              &lt;label class="radio-label rob-l" for="radio-2"&gt;No&lt;/label&gt;
            &lt;/div&gt;
            &lt;/div&gt;
          &lt;div class="btn"&gt;
            &lt;button (click)="Next()" type="submit"&gt;Next question&lt;/button&gt;
          &lt;/div&gt;
        &lt;/form&gt;
  </code></pre>
  
  <p>And I want to recieve smth like that</p>
  
  <pre><code>Next(){
      if ((this.path == 1) &amp;&amp; (this.answer === "Yes" || this.answer === "No"))
            {
              // window.dataLayer = window.dataLayer || [];
              // window.dataLayer.push({
              // 'event': 'answer',
              // 'answer': this.answer 
              // });
              this.path++;
              this.answer = "";
            }
  }
  </code></pre>
  
  <p>Problem solved with this code:</p>
  
  <pre><code>window['dataLayer'] = window['dataLayer'] || [];
          window['dataLayer'].push({
          'event': 'Answer',
          'failedText': this.answer 
          });
      ngOnInit() {
          window['dataLayer'] = window['dataLayer'] || {};
        }
  </code></pre>