Refreshing Variables after Settings Change


Hey, guys

Currently using Angular and NS with version NS 3.1.3.

I have an app that has a page with a label displaying a variable recorded from the application settings.

The problem is that the label is not updating when the settings are changed. The steps are as follows:

  • Display page with label displaying app-setting x = 1.
  • Go to settings page via button
  • change x = 2
  • use back button (Android)
  • Label still displays x = 1
  • Reload app
  • Label displays x = 2

I’ve attempted to load x in the following ways:

  • Using a method
  • via the component constructor
  • Initialise variable at declaration. i.e:
export class foo{
     x  = appSettings.getNumber("savedXValue", 0)

This is a problem I have faced exclusively in Angular. I have done the same thing in NS core and it worked fine.

If it matters, I am using “page-router-outlet” for routing pages.

I have a limited knowledge of Angular and NS, but I thought one of these techniques would work. None of them did.

I’ve searched around, but maybe my wording is incorrect. If anything this post can be an archive for future users who face this problem :smiley:

I was drunk when I wrote this, edit for readability.


The back button retrieves the parent page from cache, not firing the events you expect.

You can use the Page class in your constructor to set a navigation hook:

import { Page } from “ui/page”;

constructor( private page:Page ) {, (e:NavigatedData) => {     
        if (e.isBackNavigation) {  // this is fired on back navigation to this page 
           x = appSettings.getNumber(“savedXValue”, 0)


This works great! Thank you!

I’ll do some more research into the navigation events to make sure it doesn’t trip me up in the future. Thanks again! :smiley: