我的Angular材料中出现错误:
compiler.js:466 Uncaught Error: Template parse errors:
'mat-label' is not a known element:
1. If 'mat-label' is an Angular component, then verify that it is part of this module.
2. If 'mat-label' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
</mat-form-field>
<mat-form-field>
[ERROR ->]<mat-label>Both a label and a placeholder</mat-label>
<input matInput placeholder="Simple"):
Run Code Online (Sandbox Code Playgroud)
题:
材料标签位于MatFormFieldModule 下面是链接
现在,问题的可能原因是什么,为什么Mat-Label不为Angular Material所知.
这是HTML
Run Code Online (Sandbox Code Playgroud)<mat-form-field> <mat-label>Both a label and a placeholder</mat-label> <input matInput placeholder="Simple placeholder"> </mat-form-field>
我一直在关注PluralSight中的Angular 2入门,我看到创建的一些服务被注入App组件和模块组件中.
这是一个例子:
在Angular 2中创建RouterGuard时,创建的RouterGuard服务将注入模块级别,但某些自定义服务仅注入App Component级别.我的问题是,我应该何时将服务注入到模块级别以及何时仅注入App组件级别.
谢谢!