title: How to create a NativeView in Nativescript-Angular?
body: <p>I'm developing a mobile App with Nativescript and Angular, but I've a problem to create an <em>headerView</em> to add inside the <strong>CFAlertDialog</strong> (I'm using the plugin <em>nativescript-cfalert-dialog</em>).</p>
  
  <p>I created a service to inject to several components in my app, which is something like this</p>
  
  <pre><code>import * as application from 'tns-core-modules/application'
  
  @Injectable()
  export class PlayerDialogService {
  ...
      constructor() {
          const context = application.android.context as android.content.Context;
          this.generateAndroidNativeView(context)
  
      }
  
      private generateAndroidNativeView(context: android.content.Context) {
          this.usernameLabel = new android.widget.TextView(context)
          this.usernameLabel.setTextSize(20)
  
          this.fullNameLabel = new android.widget.TextView(context)
          this.fullNameLabel.setTextSize(16)
  
          this.playerImage = new android.widget.ImageView(context)
          this.playerImage.setMaxWidth(48)
          this.playerImage.setMaxHeight(48)
  
          this.textStackLayout = new android.widget.LinearLayout(context)
          this.textStackLayout.addView(this.usernameLabel)
          this.textStackLayout.addView(this.fullNameLabel)
  
          this.stackLayout = new android.widget.LinearLayout(context)
          this.stackLayout.addView(this.playerImage)
          this.stackLayout.addView(this.textStackLayout)
      }
  }
  </code></pre>
  
  <p>Fact is that everytime the dialog is loaded (I open a component/view that has the <code>PlayerDialogService</code> injected), I get this error:</p>
  
  <p><code>JS: ERROR TypeError: Cannot read property 'usernameLabel' of undefined</code></p>
  
  <p>I'm afraid I'm not passing the correct Context (despite it's not an empty object, nor an undefined one), but has a constructor included. So... what am I missing?</p>