2017-10-09 24 views
0

在我的角度4項目中,我有一個matTextareaAutosize,我想將最小行設置爲3,但由於某種原因,我看到最小行只有1行,可能我在我的一些錯誤代碼:material textarea不適合minRows

<mat-form-field> <textarea matInput 
    placeholder="{{ 'note.labels.note' | translate }}" 
    matTextareaAutosize matAutosizeMinRows="3" matAutosizeMaxRows = "5" 
    name="notes" #note></textarea> </mat-form-field> 

何我能讓它成功嗎?我使用的材料2.0.0.beta11 於是我跟着material

enter image description here

+0

您的模板按預期工作,您是否可以檢查控制檯是否有錯誤? – Faisal

+0

在控制檯中沒有錯誤 – Alessandro

+0

這裏是演示如期工作:https://stackblitz.com/edit/ng-mat-beta-11-qty8bv?file=app/app.component.html – Faisal

回答

0

您可以用CSS做這個最小高度和寬度屬性:

CSS

mat-form-field.txtarea { 
    min-height: 100px; 
    height: initial; 
    width: 100%; 
} 

mat-form-field textarea { 
     height: 65px; 
    } 

HTML

<mat-form-field class="txtarea"> 
    <textarea matInput name="notes" #note 
    placeholder="{{ 'note.labels.note' | translate }}"> 
    </textarea> 
</mat-form-field>