Nativescript-angular: Keep actionBar hidden after router navigation

Created on 1 Mar 2016  路  2Comments  路  Source: NativeScript/nativescript-angular

using the property actionBarHidden has no effect after the first router navigation.

public ngOnInit()
{
     topmost().currentPage.actionBarHidden = true;
}

I'm not sure if this is intended or due to the planned changes for the action bar template?

Most helpful comment

Hi @matt4446
The problem probably is that topmost().currentPage actually is the previous page as the navigation is not yet completed at the moment ngOnInit() is called.

Good news: with #104 we you can get your parent Page trough DI. So you can do the following in the component you are navigating to:

import {Page} from "ui/page";

@Component({
// ...
})
class MyComponent {
  constructor(page: Page) {
    page.actionBarHidden = true;
  }
}

All 2 comments

Hi @matt4446
The problem probably is that topmost().currentPage actually is the previous page as the navigation is not yet completed at the moment ngOnInit() is called.

Good news: with #104 we you can get your parent Page trough DI. So you can do the following in the component you are navigating to:

import {Page} from "ui/page";

@Component({
// ...
})
class MyComponent {
  constructor(page: Page) {
    page.actionBarHidden = true;
  }
}

Thanks @vakrilov

Was this page helpful?
0 / 5 - 0 ratings