有一些自定义元素和组件模板(在这个例子中,他们是由第三方非角代码中使用)属性:添加自定义元素和属性编译器架构
<foo></foo>
<div data-bar="{{ bar }}"></div>
他们导致编译器错误:
Template parse errors:
'foo' is not a known element:
1. If 'foo' is an Angular component, then verify that it is part of this module.
2. If 'foo' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
[ERROR ->]<foo></foo>
<div data-bar="{{ bar }}"></div>
"): [email protected]:4
Can't bind to 'bar' since it isn't a known property of 'div'. ("
<foo></foo>
<div [ERROR ->]data-bar="{{ bar }}"></div>
")
...
如何foo
元素和属性data-bar
被添加到编译器架构?
NO_ERRORS_SCHEMA
不是一种选择,因为不希望将其他未知元素和属性列入白名单。
谢谢,好的!我很确定DomElementSchemaRegistry类是内部的。顺便说一句,它必须是'!!(elementProperties && elementProperties [propName])'。 – estus