afe*_*eef 11 typescript angular-material angular-material2 angular
错误
没有将“exportAs”设置为“matAutocomplete”的指令(“-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto">
我使用了https://material.angular.io/components/autocomplete/overview 中的代码
我还包括在 angular 中的导入app.module.ts:
import { 
         MdAutocompleteModule,
  } from '@angular/material';
html组件
<form class="example-form">
    <mat-form-field class="example-full-width">
        <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto">
        <mat-autocomplete #auto="matAutocomplete">
            <mat-option *ngFor="let option of options" [value]="option">
                {{ option }}
            </mat-option>
        </mat-autocomplete>
     </mat-form-field>
</form>
ng--版本
@angular/cli: 1.2.1
node: 8.3.0
os: win32 x64
@angular/animation: 4.0.0-beta.8
@angular/animations: 4.3.3
@angular/cdk: 2.0.0-beta.8
@angular/common: 4.3.2
@angular/compiler: 4.3.2
@angular/core: 4.3.6
@angular/forms: 4.3.2
@angular/http: 4.3.2
@angular/material: 2.0.0-beta.8
@angular/platform-browser: 4.3.2
@angular/platform-browser-dynamic: 4.3.2
@angular/router: 4.3.2
@angular/cli: 1.2.1
@angular/compiler-cli: 4.4.3
@angular/language-service: 4.3.2
任何人都可以建议为什么 angular 抱怨。
要使用mat-form-field,您必须将@angular/material和@angular/cdk版本至少更新到2.0.0-beta.12。使用以下命令进行更新:
npm install @angular/cdk@2.0.0-beta.12
npm install @angular/material@2.0.0-beta.12
然后,您将以下内容导入到您的AppModule:
import { MatAutocompleteModule, MatFormFieldModule } from '@angular/material';
@NgModule({
    imports: [
        ....
        MatAutocompleteModule, 
        MatFormFieldModule,
        ....
    ],
    ....
})
export class AppModule { }
这是一个使用版本2.0.0-beta.12的StackBlitz 演示
| 归档时间: | 
 | 
| 查看次数: | 9956 次 | 
| 最近记录: |