Angular:Why NO_ERRORS_SCHEMA 不适用于属性?
Angular:Why NO_ERRORS_SCHEMA does not work for attribute?
我正在编写我的第一个 Angular 测试,这里遇到了问题。我正在测试一个组件,其中有一个自定义属性
<ng-container *isGranted="admin">
...
</ng-container>
The NO_ERRORS_SCHEMA tells the Angular compiler to ignore unrecognized
elements and attributes.
所以我在 TestBed
配置中添加了以下内容:
schemas: [NO_ERRORS_SCHEMA]
但是,我仍然收到错误消息:
Property binding isGranted not used by any directive on an
embedded template. Make sure that the property name is spelled
correctly and all directives are listed in the "@NgModule.declarations
我哪里错了?我不想测试 isGranted
的行为方式,我只想检查是否为其分配了正确的值。
您正在使用指令,而NO_ERROR_SCHEMA是忽略自定义组件。请参阅 github 当错误被抛出并出现适当的异常时说明您需要包含指令
Property binding ${prop.name} not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations".
我正在编写我的第一个 Angular 测试,这里遇到了问题。我正在测试一个组件,其中有一个自定义属性
<ng-container *isGranted="admin">
...
</ng-container>
The NO_ERRORS_SCHEMA tells the Angular compiler to ignore unrecognized elements and attributes.
所以我在 TestBed
配置中添加了以下内容:
schemas: [NO_ERRORS_SCHEMA]
但是,我仍然收到错误消息:
Property binding isGranted not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations
我哪里错了?我不想测试 isGranted
的行为方式,我只想检查是否为其分配了正确的值。
您正在使用指令,而NO_ERROR_SCHEMA是忽略自定义组件。请参阅 github 当错误被抛出并出现适当的异常时说明您需要包含指令
Property binding ${prop.name} not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations".