Skip to main content

onActive

onActive

Called when the page becomes active — for example, when it reappears on screen after a back gesture.

Parameters: None

Returns: No return value — this is a callback, so its return value isn't used.

Description

Called when the user returns to this page from another page, such as with the back gesture. Use it to refresh data or bring the screen state up to date at the moment the page reappears.

Example

function onActive() {
$log.i("page active");
$vm.requestData("latestPrice");
}

Related and cautions

warning

There is a similarly named onActivate, but it's an unfinished event that nothing in the codebase actually calls. Declaring an onActivate function in your script does nothing — always write code that reacts to a page becoming active again in onActive.

  • onStart fires when the page first opens; onActive fires only when you re-enter it afterward.