[SOLVED] Add user inputs?


can you add the user inputs in Angular? I am trying to display the result num + 5 in the p tag every time i change the input . Now it displays random values.

.html file

    <input #box class = "textbox" type="text" name="Name" (change)="keyup(value)>

.ts file

  providedIn: 'root'
  selector: 'app-cp1',
  templateUrl: './cp1.component.html',
  styleUrls: ['./cp1.component.css']
export class cp1 implements OnInit {
  constructor() {}

  ngOnInit(): void {

  keyup(num: number) {
    var asd = num + 5;
    this.value = asd;


In .ts declare a variable


In .html

<input [(ngModel)]="value">

But really I think you should take a tour of heroes. I know it spend some time, but give you a general idea of Angular

Answered By – Eliseo

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *