简体   繁体   English

我在我的项目中正常使用angular的最新版本中的Mat Autocomplete并得到这种类型的错误

[英]I am using Mat Autocomplete in angular's latest version using it normally in my project getting this type of error

    <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" for="id" >
    </mat-form-field>
        <mat-autocomplete #auto="matAutocomplete" id="id">

          <mat-option *ngFor="let option of options" [value]="option">
            {{ option }}
          </mat-option>
        </mat-autocomplete>

    </form>


import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
@Component({
  selector: 'app-auto',
  templateUrl: './auto.component.html',
  styleUrls: ['./auto.component.css']
})
export class AutoComponent implements OnInit {


  constructor() { }

  ngOnInit() {
  }
  myControl: FormControl = new FormControl();

  options = [
    'One',
    'Two',
    'Three'
  ];

}

在此处输入图片说明

I am getting this error when i am using it in my project in which i used material design bootstrap . 在我使用材料设计引导程序的项目中使用它时,出现此错误。

You are using id but never declared it anywhere. 您正在使用id但从未在任何地方声明它。

ts: TS:

public id = 'my-input';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Angular与Firebase一起使用时出现错误 - I am getting error using Firebase with Angular 我在使用 mat native select 时收到此“错误:mat-form-field must contain a matformfieldcontrol” - I am getting this 'Error: mat-form-field must contain a matformfieldcontrol' while using mat native select 如何为我在 Angular 版本中使用的库找到最新的稳定版本 - How to find the latest stable version for the libraries I am using in an Angular version 我正在使用 fakeAsync 并在 angular 的单元测试用例中打勾,但仍然在队列中出现错误 2 定期计时器 - I am using fakeAsync and tick in unit test case of angular , getting error 2 periodic timer(s) still in the queue 使用 angular 表单 ControlValueAccessor 和 mat-autocomplete - Using angular form ControlValueAccessor and mat-autocomplete 使用 Angular 材料将 mat-select 转换为 mat-autocomplete - Convert mat-select to mat-autocomplete using Angular Material 在 Angular http 服务中使用 pokeApi 时出现错误 - I am getting an error when using pokeApi in Angular http service 我正在尝试使用角度上传图像但出现错误 - I am trying to upload image using angular but getting error 当我尝试在我的 Angular 项目中添加引导程序时出现此错误 - I am getting this error when i try to add bootstrap in my Angular project 为什么将我的 Angular 项目部署到 Heroku 时出现 ng not found 错误? - Why am I getting an ng not found error when deploying my Angular project to Heroku?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM