注入页面为空

apr*_*ity 4 nativescript angular2-nativescript

将 angular nativescript 项目升级到 angular、typescript、tns 等的当前版本后。我收到一个运行时错误,指出:

类型错误:无法在新的 AppComponent 中将属性“actionBarHidden”设置为 null...

以前用于隐藏操作栏的代码如下所示:

import {Page} from "tns-core-modules/ui/page";

export class AppComponent implements OnInit, AfterViewInit {

    constructor(page: Page) {
        page.actionBarHidden = true;
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么注入后页面为空?

Man*_*noj 5

在早期版本中,根总是 a Frame,所以默认情况下会有一个Page.

但是在最新版本中,您可以page-router-outlet在应用程序中定义灵活的根组件和任意数量的框架 ( )。所以在 app 组件中不会有一个默认的Frame/Page创建的。Page只能注入到加载在page-router-outlet.