繁体   English   中英

无法绑定到“已禁用”,因为它不是&#39; <button>&#39;</button>的已知属性

[英]Can't bind to 'disabled' since it isn't a known property of '<button>'

我刚开始学习Angular,但是我遇到以下错误:无法绑定到'disabled',因为它不是<button>的已知属性。 在互联网上搜索我发现了类似的错误,但它们与未导入FormsModule的事实有关,这似乎不是我的情况。

app.components.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  Button = false;
}

app.component.html

<div style="text-align:center">
  <h1>
    Welcome to {{title}}!!
  </h1>
  <button [Disabled]="!Button">Click me</button>
</div>

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    FormsModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

试试这个

 <button [disabled]="!Button">Click me</button>

暂无
暂无

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

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