I am learning angular from basic in my code I want to send text from text box on enter to function when I tried with just keyup keydown it was working fine but when try to use submit keyup.enter the whole component disappear
diagnos.component.html:
<input type="text" #nameText (keyup.enter)="addItem(nameText.value)">
<ul>
<li *ngFor="let name of names">{{name}}</li>
</ul>
diagnos.component.ts:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-diagnos',
templateUrl: './diagnos.component.html',
styleUrls: ['./diagnos.component.css']
})
export class DiagnosComponent implements OnInit {
names = ['abc','xyz'];
constructor() { }
ngOnInit(): void {
}
addItem(val){
this.names.push(val);
}
}
when used keyup.enter or submit after pressing enter or submitting:

after enter or submit whole component disappeared even that ul also and had tried logging on console if that function get call or not but that function doesn't call
my project link : https://github.com/ladbhupesh/angularapp

