在输入文本字段中,[object Object]显示在占位符而不是预期的占位符Angular

时间:2017-10-20 06:35:41

标签: angular input placeholder

在处理Angular反应表单时,我在向文本字段赋予占位符值时遇到问题,在占位符[object Object]中显示而不是预期的占位符。

<span *ngIf="selectedControl">
   <label>{{selectedControl.attributes.attributeName}}</label>
   <input type="{{selectedControl.attributes.type}}" [(ngModel)]="selectedControl.attributes.value">          
</span>

<div 
    class="form-group"
    *ngFor="let control of reviewForm.get('controlArray').controls; let i = index">            
    <label>{{label}} </label>                                      
    <input 
        type="{{control.value}}" 
        placeholder="selectedControl.attributes.value"                     
        class="form-control"                                                       
        [formControlName]="i"
    >                       
</div> 

这是我存储占位符和其他信息的对象。

{
   name:'text', attributes: {attributeName: 'Placeholder', type:'text', value:''}            
}

这就是我为selectedControl赋值的方法:

<select [(ngModel)]="selectedControl" class="form-control" (click)="onSelection($event)">
      <option *ngFor="let control of controlArray; let i=index" 
        [ngValue]="control">{{controlArray[i].name}}</option>                                              
</select>

请帮忙。感谢

0 个答案:

没有答案