I am working on an Angular project and I need to pass one of my input values to a TypeScript function. However, when I try to console.log it, the updated value is not displayed.
<div class="form-group">
<input type="number" [name]="'sec_chlng'" (click)="func()"
placeholder="Security Challenge: {{a}}+{{b}}" class="form-control form-
control-lg" required></div>
Below is my TypeScript file:
import { Component, OnInit } from '@angular/core';
import { Input } from '@angular/core';
import { ElementRef } from '@angular/core';
@Component({
selector: 'angly-signUp',
templateUrl: './signUp.component.html',
styleUrls: ['./signUp.component.scss']
})
export class SignUpComponent implements OnInit {
a = Math.floor(Math.random() * 10) + 1 ;
b = Math.floor(Math.random() * 10) + 1 ;
c = this.a + this.b;
@Input() sec_chlng : any;
constructor(private elementRef: ElementRef) {
}
ngOnInit() {
}
func(){
console.log(this.sec_chlng);
}
}
Any suggestions on how to update the values?