I have an angular 2 app that displays the username in the text input as a text. What I do is to get user from my component using userService and display it on my html template. Here is my input html field:
<div class="row" *ngFor="let user of users">
<div class="col-md-5 mb-2">
<label>Researcher:</label>
<input id="createdBy" type="text" class="form-control"
[(ngModel)]="screen.createdBy" name="createdBy"
required #createdBy="ngModel"
placeholder="{{ user.firstName }}"
ngValue="user.firstName"
>
</div>
I use placeholder attribute to test to make sure I retrieve the user first name and I do. Placeholder displays it. But I need to display user's first name as a value of the text field just like asp.net.
I've tried ngValue and value attributes but I couldn't get that. FormsModule and BrowserModule are defined in the app.module.ts file. I will be appreciated if you could show me where I am missing.