小编Ran*_*z67的帖子

'mat-label'不是已知元素最新Angular材质中的错误

我的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

<mat-form-field>
          <mat-label>Both a label and a placeholder</mat-label>
          <input matInput placeholder="Simple placeholder">
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)

angular-material angular

13
推荐指数
2
解决办法
3万
查看次数

何时将Service注入Angular 2模块级别和App组件级别

我一直在关注PluralSight中的Angular 2入门,我看到创建的一些服务被注入App组件和模块组件中.

这是一个例子:

在Angular 2中创建RouterGuard时,创建的RouterGuard服务将注入模块级别,但某些自定义服务仅注入App Component级别.我的问题是,我应该何时将服务注入到模块级别以及何时仅注入App组件级别.

谢谢!

dependency-injection angular

6
推荐指数
1
解决办法
2045
查看次数