我有一个库项目,我正在迁移到Angular 6和Angular CLI 6。
有一个名为NativeFormElementChild
的抽象类,它有一些私有属性:_id
,_required
,_ariaDescribedBy
和_ariaRequired
。
然后我有一个指令,InputDirective
,它被应用于<input>
作为属性(添加了一些额外的功能)。 InputDirective
从NativeFormElementChild
延伸。
现在,当我尝试在Angular 6中构建它时,我得到的错误很多。我到处使用我的InputDirective
,我得到四个错误:
我不是试图从NativeFormElementChild
内部的任何地方访问这些属性。所以我不知道这些错误来自哪里。使用Angular 5,我没有得到任何这些错误。
在组件html中,将*ngIf="true"
放在最外面的html标记中。这似乎激活了Angular 6对受保护属性的理解。任何*ng
标签(模板绑定)都可以。每个组件html都需要一个。
<div *ngIf="true">
...Everything in here will now properly have access to protected properties
</div>
或者,如果你没有外部元素,你可以使用ng-container
...
<ng-container *ngIf="true">
...
</ng-container>