Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I just started learning Angular but I'm having the following error: Can't bind to 'disabled' since it isn't a known property of <button>. Searching on internet I just found similar errors but they are related to the fact the that the FormsModule is not imported, that doesn't seem to be my case.

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 { }
like image 338
Leandro Lorenzini de Oliveira Avatar asked Jul 08 '17 14:07

Leandro Lorenzini de Oliveira


People also ask

Can't bind since it isn't a known property?

What does "Can't bind to 'x' since it isn't a known property of 'y'" mean? link. This error often means that you haven't declared the directive "x" or haven't imported the NgModule to which "x" belongs. Perhaps you declared "x" in an application sub-module but forgot to export it.

Can't bind to readOnly since it isn't a known property of select?

Can't bind to 'readOnly' since it isn't a known property of 'ng-select'. If 'ng-select' is an Angular component and it has 'readOnly' input, then verify that it is part of this module. If 'ng-select' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.


1 Answers

Try this

 <button [disabled]="!Button">Click me</button>
like image 119
alehn96 Avatar answered Sep 18 '22 12:09

alehn96