title: Angular : Fetch value of textbox onclick of button
body: <p>I want to print the value of textbox when i click of button. But it throws nullpointerexception. I also need to keep some value in the textbox i dont understand why?. Whatever i type in textbox and when i click on buttom i need to print the value of textbox What is the issue?</p>
  
  <p>Below is my code:</p>
  
  <p><strong>ts file</strong></p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  
  @Component({
    selector: 'app-mypage',
    templateUrl: './mypage.component.html',
    styleUrls: ['./mypage.component.scss']
  })
  export class mypageComponent implements OnInit {
  
    constructor(private router: Router) {
  
    }
  
    ngOnInit() {
    }
  
  
  
    myFunc() {
  
        var num1 = ((document.getElementById("exchageRateDate") as HTMLInputElement).value);
        console.log(num1);
    }
  
  }
  </code></pre>
  
  <p><strong>HTML File</strong></p>
  
  <pre><code>&lt;br&gt;Welcome.&lt;br&gt;
  Place - &lt;input type="text" value="Sydney" ng-model="placeId" /&gt;
  &lt;button (click)="myFunc(placeId)" formtarget="_blank"&gt;Test&lt;/button&gt;
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>ERROR TypeError: Cannot read property 'value' of null
  </code></pre>