有一些自定義元素和組件模板(在這個例子中,他們是由第三方非角代碼中使用)屬性:添加自定義元素和屬性編譯器架構
<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