I am pretty new with Angular 4 and I have probably basic question for someone who is a bit more experienced than me.
I have input field which value needs to be populated when object user exists. So basically I need php function isset() in angular 4.
I tried like this but it is not working.
<input class="form-control" type="text" value="{{ !!user.firstname ? user.firstname : null }}" id="firstname">
Any help would be appreciated.
Tnx
I am pretty new with Angular 4 and I have probably basic question for someone who is a bit more experienced than me.
I have input field which value needs to be populated when object user exists. So basically I need php function isset() in angular 4.
I tried like this but it is not working.
<input class="form-control" type="text" value="{{ !!user.firstname ? user.firstname : null }}" id="firstname">
Any help would be appreciated.
Tnx
Share Improve this question asked Oct 20, 2017 at 10:22 dj.milojevicdj.milojevic 2141 gold badge5 silver badges12 bronze badges 1- 1 use [(ngModel)] instead of value – Shubham Agrawal Commented Oct 20, 2017 at 10:26
2 Answers
Reset to default 3You should use [(ngModel)] with input and use elvis operator to check if the user exists or use *ngIf
<input class="form-control" type="text" [(ngModel)]=user?.firstName id="firstname">
Try this :
<input class="form-control" type="text" [value]="user.firstname ? user.firstname : null" name="firstname" id="firstname">
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745107070a4611622.html
评论列表(0条)