AoT NGC/Angular2:属性受到保护,只能在类Error中访问

mes*_*lds 7 ionic2 angular

在我使用的Angular 2/Ionic 2(final/rc0)项目中的组件中:

protected contentTarget: ViewContainerRef;

ngOnInit() {
        this.contentTarget.createComponent(componentFactory);
    }
Run Code Online (Sandbox Code Playgroud)

AoT编译器说:

Error at ....: Property 'contentTarget' is protected and only accessible within class 'IncludeTemplateComponent' and its subclasses.
Run Code Online (Sandbox Code Playgroud)

变量(属性)不会在整个项目中的任何其他位置使用.

那么......任何人都可以对此有所了解,是createComponent工厂将contentTarget变量传递给它的子节点,或者为什么编译器不喜欢这里受保护?现在所有Angular2中的受保护变量都是"被禁止的"吗?

Mat*_*Nls 11

这里开始

对于给定组件,其模板访问的所有成员(方法,属性)必须在提前编译方案中是公共的.这是因为模板被转换为TS类.生成的类和组件现在是2个单独的类,您不能访问跨类的私有成员.

我的看法是contentTarget由模板引擎使用,因此,AOT必须公开才能工作.