Kla*_*urn 40 material-design angular-material2 angular
我有一个混合的Angular1和Angular2应用程序.在我路由到的一个Angular2组件中,我想使用Material Design Button.
当我像这样<md-button>foo</md-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>"): JobComponent@0:12
at TemplateParser.parse (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:8321:21)
Run Code Online (Sandbox Code Playgroud)
所以,它听起来就像是消息的情况下,1,但我已经试过在给出的建议这个答案添加MdButton到imports我的财产NgModule(其中已经包含MaterialModule.forRoot()由作为劝文档),但如果我这样做,整个应用程序在控制台中出现空白而没有错误.
这是一些相关的代码
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"]);
Run Code Online (Sandbox Code Playgroud)
mic*_*yks 59
它应该是
<button md-button>foo</button>
Run Code Online (Sandbox Code Playgroud)
要么
<button md-raised-button>foo</button>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
58346 次 |
| 最近记录: |