I have a code:
document.getElementById(\'loginInput\').value = \'123\';
But while compiling the code I receive following error:
Complate Angular Way ( Set/Get value by Id ):
// In Html tag
// In component .ts File
export class testUserClass {
@ViewChild('userNameId') userNameId: ElementRef;
ngAfterViewInit(){
console.log(this.userNameId.nativeElement.value );
}
setValue(){
this.userNameId.nativeElement.value = "Sample user Name";
}
}