Is it required for the md-input-container to include the mdInput directive?

Currently, I am working on an Angular 2 project where I am implementing angular Material. While trying to add the

<md-input-container></md-input-container>
element, I encountered the following error:

Error: md-input-container must contain an mdInput directive. Did you forget to add mdInput to the native input or textarea element?

I attempted to troubleshoot this issue by searching online, but unfortunately, I couldn't find a relevant solution. Can anyone provide guidance on what mistake I might be making? Here is my code snippet for reference:

app.component.ts:

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

@Component({
  selector: 'my-app',
  template: `<h1>Hello {{name}}</h1>

<md-input-container>
  <input md-input placeholder="Favorite food" value="Sushi">
</md-input-container>`,


styleUrls: [ './app/css/style.css' ],
})
export class AppComponent  { name = 'Angular'; }

app.module.ts:

import { NgModule                                     }   from '@angular/core';
import { BrowserModule                                }   from '@angular/platform-browser';
import { MaterialModule                               }   from '@angular/material';
import { AppComponent                                 }   from './app.component';
// import 'hammerjs';

@NgModule({
  imports:      [ MaterialModule.forRoot(),BrowserModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

system.config.js:

(function (global) {
  System.config({
    paths: {
      'npm:': 'node_modules/'
    },
    map: {
      app: 'app',

      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/material': 'npm:@angular/material/bundles/material.umd.js',

      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
    },
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <link rel="stylesheet" href="node_modules/@angular/material/core/theming/prebuilt/deeppurple-amber.css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </head>

  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>
</html>

Answer №1

Identifying as mdInput:

<md-input-container>
  <input mdInput placeholder="Favorite food" value="Sushi">
</md-input-container>

For a comprehensive list of changes, review the Complete Changelog which includes major updates.

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

Having trouble with Dynamic Components not functioning properly when loaded after ViewInit

Why is it that the code below isn't functioning as expected? Why does @ViewChildren seem unable to recognize the ng-containers? HTML <div [innerHtml]="html"></div> Controller: import { Component, ViewChildren, AfterViewInit, QueryList, ...

What is the method for displaying script commands within package.json files?

With a multitude of repositories, each one unique in its setup, I find myself constantly referencing the package.json file to double-check the scripts. "scripts": { "start": "npm run dev" "build:dev": "N ...

Running Jest tests concurrently causes a TypeError due to converting a circular structure to JSON

While running Jest Tests in parallel, I encountered the following error. Interestingly, when running each test individually or using --RunInBand, they all pass without any issues. Test suite failed to run Jest worker encountered 4 child process except ...

Expand the data retrieved from the database in node.js to include additional fields, not just the id

When creating a login using the code provided, only the user's ID is returned. The challenge now is how to retrieve another field from the database. I specifically require the "header" field from the database. Within the onSubmit function of the for ...

Discover the perfect way to implement true lazyloading using NativeScript Angular tabs and BottomNavigation

Currently working on an app using nativescipt, I've successfully added BottomNavigation with lazy loading and Tab components in child pages. The code structure resembles the following: export const routes: Routes = [ { path: '', red ...

Angular: Placing two child components within a single form element in the parent component

Creating a page with Angular 7 featuring repeating structures First Step Checkbox: title : -------- Message1 : -------- Message2 : -------- Message3 : -------- Message4 : -------- Second Step Checkbox: title : --- ...

Sending data to an API in order to update an object can be accomplished when the controller is handling an Observable within Angular 6

Currently I am utilizing Angular 6 for creating a few basic features and encountering some difficulties with Observables. In one of my components, I retrieve a project on initialization: ngOnInit() { this.project$ = this.route.paramMap.pipe( sw ...

Leveraging functionality from an imported module - NestJS

Currently, I am utilizing a service from a services module within the main scaffolded app controller in NestJS. Although it is functioning as expected - with helloWorldsService.message displaying the appropriate greeting in the @Get method - I can't ...

"NGRX is like the magician who pulls off the trick successfully before

I encountered an issue where I throw an exception in my service, attempt to catch it in my effect, and display the appropriate toast message on the frontend. Current Behavior: After receiving a success message, an error is thrown. Although I can see the e ...

Display the label and hide the marker on the map

I have integrated openStreetMap into my Angular 6 application as shown below. Adding a marker to the map works perfectly fine, but displaying a label when the marker is clicked seems to be a challenge for me and I'm unsure why. Additionally, I am puzz ...

The system could not find the command "tsc" as an internal or external command, or as an operable program or script file

I'm new to using type script and I'm having trouble compiling my files. When I press Ctrl+Shift+B in VS Code, I receive the error message "tsc is not recognized." I installed typescript using npm. C:\Users\sramesh>npm install -g t ...

Changing a d3 event from JavaScript to Typescript in an Angular2 environment

I am a beginner in Typescript and Angular 2. My goal is to create an Angular2 component that incorporates a d3js tool click here. However, I am facing challenges when it comes to converting it to Typescript. For instance, I am unsure if this code rewrite ...

Sorting character values in TypeScript using ascending and descending order in a JSON array

In my dataset of homes, I have the following information: var homes = [ { "h_id": "3","city": "Dallas","state": "YYYY","zip": "75201","price": "162500" }, { "h_id": "4","city": "CA","state": "ZZZZ","zip": "90210","price": "319250" }, { "h ...

Provider with factory for the root Angular 6 library

I'm currently in the process of developing a library that requires a configuration input from the host application. During the building phase of the library, I encounter the following warning: Warning: Can't resolve all parameters for CacheServ ...

ESLint is indicating an error when attempting to import the screen from @testing-library/react

After importing the screen function from @testing-library/react, I encountered an ESLint error: ESLint: screen not found in '@testing-library/react'(import/named) // render is imported properly import { render, screen } from '@testing-lib ...

How can I fully mock a component in an Angular Unit Test, rather than just a single class?

In my current task, I am faced with the challenge of unit testing a component that relies on a subcomponent. The subcomponent utilizes CanvasJS for displaying plots, but this poses issues when running Jest Unit Tests. As of now, in my spec file, the follo ...

Having trouble centering an icon in a cell within AG Grid?

I am struggling with aligning my checkmarks within the cells of my AG Grid. Currently, they are all left aligned but I need them to be centered. Adjusting the alignment for text is not an issue, but I can't seem to center the material icons. It appear ...

Using Angular Material to dynamically hide columns in a table that is being created on the fly

Is there a way to hide columns in my table based on the ID value sent to the page upon opening it? While researching, I found a method for tables with dynamically generated columns in this post: https://github.com/angular/components/issues/9940. However, t ...

Having Trouble Retrieving Data from Observable in Angular 2 and Typescript

I've encountered a promise error when trying to access a variable that receives data from an observable. Here's an example: Within my component, I have defined the Stat class: export class Stats { name: string; percentage: number; constru ...

What is the best way to send parameters from an Angular application to a Node.js API?

How can I correctly pass the id from Angular to my "/rating" HTTP endpoint? This is the method I am currently using: apiUpdateRating(id){ return this.http.get('http://localhost:8080/rating', { params:id }); } When ...