I need the user to be able to type in a number in the given input field and when they click on the submit button, it runs a javascript function that returns the factorial. How do I send the user’s input value to the javascript function? I found this online but it doesn’t seem to work: (P.S: I am using Angular)
export class FormComponent implements OnInit {
findFactorial() {
const number = document.querySelector(".number_field").value;
console.log(number);
}
constructor() {}
ngOnInit() {}
}
<form class="form">
<mat-form-field class="full-width">
<input
matInput
class="number_field"
type="number"
placeholder="Enter A Number"
max="1000000000"
/>
</mat-form-field>
</form>
<button class="btn" mat-raised-button color="primary" (click)="findFactorial()">
Submit
</button>