title: Passing parameters in functions in Angular 6?
body: <pre><code>import { Component, OnInit } from '@angular/core';
  
  @Component({
   selector: 'app-calculator',
   templateUrl: './calculator.component.html',
   styleUrls: ['./calculator.component.css']
  })
  
  export class CalculatorComponent implements OnInit {
    public result:number=0;
    public num:number=0;
    public final:number=0;
  
    constructor() { }
  
    ngOnInit() {
    }
    onClick(e){
      this.num = Number(e.target.value);
      this.result = this.num+this.result;
      if(e.target.value == "="){
        console.log(this.result); // the output of console here is : null
        this.display();
      } 
    }
  
    display(){
        console.log(this.result); // here the console output is : NaN
        this.final = this.result;
    }
  
  }
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div&gt;
    &lt;input type="number" value="{{result}}"&gt;&lt;br&gt;&lt;br&gt;
    &lt;button value="1" (click)="onClick($event)"&gt;1&lt;/button&gt;&amp;nbsp;&amp;nbsp;
    &lt;button value="2" (click)="onClick($event)"&gt;2&lt;/button&gt;&amp;nbsp;&amp;nbsp;
    &lt;button value="=" (click)="onClick($event)"&gt;=&lt;/button&gt;&lt;br&gt;&lt;br&gt;
    Result : {{final}}
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to print the result in the display function but it is not doing so.
  even in the onClick() function the result in the if statement is not scopeable.
  I want to print the result in the display function </p>