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
您应该在输入中使用[[ngModel)]并使用elvis运算符检查用户是否存在或使用*ngIf
<input class="form-control" type="text" [(ngModel)]=user?.firstName id="firstname">
尝试这个 :
<input class="form-control" type="text" [value]="user.firstname ? user.firstname : null" name="firstname" id="firstname">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.