Error message: "An issue related to md-input binding has been found in the

I encountered a common error while trying to upgrade an app from angular2 to the stable version. Unfortunately, none of the suggested solutions worked for me, even though there seems to be only one widespread solution available. Here's the error message:

Template parse errors:
Can't bind to 'placeholder' since it isn't a known property of 'md-input'.
1. If 'md-input' is an Angular component and it has 'placeholder' input, then verify that it is part of this module.
2. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.

I attempted to import the FormsModule based on this solution1 and this solution2 (which essentially provide the same solution), but the error persists. Is there another workaround available?

Here is the relevant HTML code snippet:

  <div class="col-lg-10 col-lg-offset-1">
      <div class="md-block">
        <md-input
          id="name"
          [ngModel]="xyzStuff?.xyz_name"
          placeholder="{{'xyzName' | translate}}"
          formControlName="name"
          dividerColor="{{getDividerColor(xyzForm.controls.name)}}"
        >
        </md-input>
      </div>
    </div>

and the corresponding Module file:

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

import { UIRouterModule } from 'ui-router-ng2';
import { TranslateModule } from 'ng2-translate';

import { ParComponent } from './par.component';
import { XyzSettingsComponent } from './shared/xyz-settings/xyz-settings.component';

@NgModule({
  declarations: [
    ParComponent,
    XyzSettingsComponent
  ],
  imports:       [
    FormsModule,
    BrowserModule,
    UIRouterModule,
    TranslateModule,
    ReactiveFormsModule
  ],
  providers:     [],
  exports:       [
    FormsModule,
    BrowserModule,
    UIRouterModule,
    TranslateModule,
    ReactiveFormsModule
  ]
})
export class ParModule {}

Any assistance would be greatly appreciated.

Answer №1

md-input is a component of the angular2 material project. Please note that Angular 2 Material is a completely separate plugin. To utilize it, you need to ensure that you import and inject MaterialModule within the imports option of your NgModule.

import { MaterialModule } from '@angular/material';

@NgModule({
  declarations: [
    ...
  ],
  imports:       [
    ...,
    MaterialModule.forRoot(), //<-- imported material module here
    ...
  ],
  providers:     [],
  exports:       [
    ...
  ]
})

I highly recommend checking out the Getting started page for Angular2 Material

Note: When using Angular 2 material components, remember to import MaterialModule in the modules of the components you want to utilize.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The system is unable to locate a supporting entity with the identifier '[object Object]', as it is classified as an 'object'

I'm currently working on an Angular 2 application where I am retrieving data from an API and receiving JSON in the following format. { "makes": null, "models": null, "trims": null, "years": null, "assetTypes": { "2": "Auto ...

Issues encountered when working with Angular Material 2

Embarking on my project with Angular-material2 has proven to be quite challenging. Despite my efforts to import components correctly, I am encountering errors after importing material modules in my app.module.ts file. The error message reads: Uncaught Err ...

What should I do to resolve the error when "HttpClient" name is not found?

Whenever I attempt to start my project using npm start, I encounter an error: [at-loader] Checking completed with 1 error [at-loader] ./node_modules/@ngx-translate/http-loader/src/http-loader.d.ts:10:23 TS2304: Cannot find name 'HttpClient' ...

Dealing with mistakes in an Angular service

I've been grappling with error handling in Angular. I attempted to handle errors within a service, but I'm uncertain if that's the correct approach. @Injectable({ providedIn: 'root', }) export class CaseListService { public con ...

Maximizing the potential of typescript generics in Reactjs functional components

I have a component within my react project that looks like this: import "./styles.css"; type InputType = "input" | "textarea"; interface ContainerProps { name: string; placeholder: string; as: InputType; } const Conta ...

Establishing foreignObject coordinates in Angular

Struggling with setting the position (x, y) for foreignObject in Angular. I have attempted the following: <foreignObject width="65" height="50" x="{{position?.x}}" y="{{position?.y}}"> <div class="c ...

Tips for transferring the clicked value to the next page

Recently, I started working with Ionic and developed an application using it. Now, I am facing a challenge where I need to pass the value from the first page to the second page. To illustrate this more clearly, I have attached two photos. Here is the imag ...

Issue with TypeScript: Difficulty accessing keys in a recursive manner

I've created a custom type that eliminates any nullish values when working with objects. export type ExcludeNullish<T> = Exclude<T, null | undefined>; export type ExcludeNullishKeys<T> = { [K in keyof T]-?: T[K] extends boolean | ...

Implement a function for templateURL in AngularJS using Typescript programming language

Here is my current setup: export class MyComponent implements ng.IComponentOptions { public static componentName: string = "myViewer"; public bindings: any; public controller: any; public controllerAs: any; public templateUrl: string; ...

Creating a form using the reactive form approach

Initially, the parent form was created. However, I found it necessary to include another form inside it because the attributes were the same as those in the parent form. This is how I approached it: <div formControlName="pessoa"> <d ...

Tips for ensuring that npm only creates one instance of a dependency when it is being used by multiple projects

Struggling a bit here. I am diving into npm and configuration files for the first time. The current challenge involves setting up a vue project (though it might not be directly related to the issue) with typescript and then reusing its code and components. ...

Angular encountered an error while attempting to manage a base service that was not defined

My service involves extending a base service to handle error data effectively. For instance import { CurrentUserService } from './current-user.service'; import { CONFIG } from './../shared/base-urls'; import { BaseServiceService } fro ...

Every Angular project encounters a common issue with their component.ts file

After watching several Angular 7 project tutorials on YouTube, I found myself struggling with a basic task - passing a name from the component.ts file to the component.html file. The current output of my code simply displays "Hello" without the actual nam ...

Learn how to incorporate the dynamic array index value into an Angular HTML page

Exploring Angular and facing a challenge with adding dynamic array index values in an HTML page. Despite trying different solutions, the answer remains elusive, as no errors are being thrown. In TypeScript, I've initialized an array named `months` wh ...

What is the correct way to specify type hints for a Stream of Streams in highlandjs?

I'm currently working with typescript@2 and the highlandjs library. In the typings for highland, there seems to be a missing function called mergeWithLimit(n). This function: Accepts a Stream of Streams, merges their values and errors into a single ...

What is the best way to create an array of strings that can include multiple elements from a set of strings?

Exploring different roles for authorization: ['admin', 'manager', 'user'] Is there a way to create a specific type, named Roles, which is essentially a string array ( string[] ) that is limited to only containing values from ...

What are the steps to resolve the MSB4132 error in MSBUILD on a Windows 10 system?

Currently working on an Angular 2 project while using Windows 10. When I ran npm install, I encountered this error message: MSBUILD : error MSB4132 MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. The available tools versions are "12. ...

Exploring i18nNext integration with antd table in React

Presently, this is the UI https://i.stack.imgur.com/CMvle.png App.tsx import "./styles.css"; import MyTable from "./MyTable"; export default function App() { const data = [ { key: "1", date: "2022-01- ...

Rxjs: Making recursive HTTP requests with a condition-based approach

To obtain a list of records, I use the following command to retrieve a set number of records. For example, in the code snippet below, it fetches 100 records by passing the pageIndex value and increasing it with each request to get the next 100 records: thi ...

Instructions on retrieving keyboard input values from Angular's Material Datepicker using Reactive Forms

Currently, I am using Angular along with material datepicker within Reactive Forms and moment's MomentDateModule. My concern lies in extracting the value that a user types into the form via keyboard input. If you wish to see an example of this scenar ...