A different approach, i.e: You could just do it 'the Angular way' and use ngModel
and skip document.getElementById('loginInput').value = '123';
altogether. Instead:
<input type="text" [(ngModel)]="username"/>
<input type="text" [(ngModel)]="password"/>
and in your component you give these values:
username: 'whatever'
password: 'whatever'
this will preset the username and password upon navigating to page.