저는 하이브리드 Angular1 및 Angular2 응용 프로그램이 있습니다. 경로를 지정하는 Angular2 구성 요소 중 하나에서 Material Design Button을 사용하려고합니다. 나는 응용 프로그램이재질 디자인 구성 요소가 "알려진 요소가 아닙니다."
Error: Template parse errors:
'md-button' is not a known element:
1. If 'md-button' is an Angular component, then verify that it is part of this module.
2. If 'md-button' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<h1>Job</h1>[ERROR ->]<md-button>material</md-button>"): [email protected]:12
at TemplateParser.parse (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:8321:21)
그래서이 콘솔 메시지와 함께 충돌 시작이 <md-button>foo</md-button>
같은 템플릿에 버튼을 삽입 할 때이 메시지의 경우 1처럼
, 그것은 들릴 수도 있지만 내가 조언을 시도했다 this answer에서 (이미 을 포함하고 있음)의 imports
속성에 imports
속성을 추가하면됩니다.하지만 그렇게하면 전체 응용 프로그램이 콘솔에 오류없이 공백이됩니다. 여기
import { UIRouterModule } from "ui-router-ng2";
import { Ng1ToNg2Module, uiRouterNgUpgrade } from "ui-router-ng1-to-ng2";
import { MaterialModule, MdButton } from '@angular/material';
const upgradeAdapter: UpgradeAdapter = new UpgradeAdapter(
forwardRef(() => XamFlowNg2Module));
uiRouterNgUpgrade.setUpgradeAdapter(upgradeAdapter);
angular.module("xamFlow")
.factory("consoleService",
upgradeAdapter.downgradeNg2Provider(ConsoleService));
/*
* Expose our ng1 content to ng2
*/
upgradeAdapter.upgradeNg1Provider("restService");
@NgModule({
declarations: [
JobComponent,
],
entryComponents: [
// Components that are routed to must be listed here, otherwise you'll get "No Component Factory"
JobComponent,
],
imports: [
CommonModule,
BrowserModule,
FormsModule,
HttpModule,
Ng1ToNg2Module,
MaterialModule.forRoot()
],
providers: [
ConsoleService,
ImageService
]
})
class MyModule { }
upgradeAdapter.bootstrap(document.body, ["myApp"]);
루트'@NgModule()'('https://github.com/angular/material2/blob/ ')의'imports : [...]'에'MaterialModule.forRoot() fcc5900e496adc5b11e47ad1e6d3e0c2ac2bad9e/GETTING_STARTED.md)? –
관련 코드를 보여 주시겠습니까? – micronyks
@ GünterZöchbauer 내가 그랬어. –