Materials 3, trying to get started with Angular 17 #5351
-
I've read all the docs. I still can work out how to use this in my Angular 17 project. I do this, npm install @material/web, and then import a component, like this, import {MdOutlinedTextField} from '@material/web/textfield/outlined-text-field.js' After that I try import MdOutlinedTextField, into the component, but cannot , as it complains that the import is for standalone components only Then including this, , in the html, gives this: Application bundle generation failed. [0.389 seconds] src/app/2. contract-module/edit-tabs/personal-information-edit/personal-information-edit.component.ts:27:120: Sorry, I'm a beginner : ( The Quick User Guide is a bit too brief on step by step instructions... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The custom element class Instead, you should import the component registration as a side effect and enable its use with // Import custom element registrations. These are called side-effect imports.
// You can import them all at once, or in each individual Angular component that
// uses them (better for tree-shaking and code splitting).
import '@material/web/textfield/outlined-text-field';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@NgModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class MyModule {} |
Beta Was this translation helpful? Give feedback.
The custom element class
MdOutlinedTextField
cannot be registered in the@NgModule
's components array since it isn't an Angular component.Instead, you should import the component registration as a side effect and enable its use with
schemas: [CUSTOM_ELEMENTS_SCHEMA]
in your@NgModule
or@Component
metadata.