简体   繁体   中英

Angular Material placeholder on input doesnt flow

I'm using Angular Material 6.4.5 and I have problem with floating my placeholder.

this is my html

<mat-form-field class='search'>
   <input matInput placeholder='Search' value='book' [(ngModel)]='search'>
</mat-form-field>

在此处输入图片说明

I also have problem with my mat-select it doesn't open

<mat-form-field>
   <mat-select placeholder="Test">
     <mat-option *ngFor="let foo of test" [value]="foo.id">{{foo.lastName}}</mat-option>
   </mat-select>
</mat-form-field>

Is there any idea what wrong, I tried whole afternoon and with no success.

Property name is mandatory for input element with [(ngModel)]

<mat-form-field class='search'>
   <input matInput placeholder='Search' name="search" value='book' [(ngModel)]='search'>
</mat-form-field>

I forget to import theme in my styles.css. Everything works now

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM