Guide on refreshing a page from a different class using Ionic3

I have two main folders named /HomePage and /SettingsPage.

/HomePage consists of:

  • home.html
  • home.ts

The second folder, /SettingsPage, includes:

  • settings.html
  • settings.ts

My goal is to refresh the content in HomePage (home.html) using code from settings.ts

To reload or refresh settings.html, I use the following code:

this.navCtrl.setRoot(this.navCtrl.getActive().component);

Answer №1

If you're looking to trigger a reload event, consider using the Events feature:

import { Events } from 'ionic-angular';

// SettingsPage (emit an event to signal HomePage to reload)
constructor(public events: Events) {}

shouldReload() {
  events.publish('shouldReloadData');
}


// HomePage (listen for the event and perform reload)
constructor(public events: Events) {
  events.subscribe('shouldReloadData', () => {
    // Perform page reload logic here
  });
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The seamless pairing of Cucumber and Playwright: Cucumber's inability to retain cookies results in a login attempt with every scenario

I am currently facing an issue with integrating cucumber and playwright into my framework. When attempting to execute various features or multiple scenarios within one feature, I encounter a problem where if one scenario logs into a site, the other scenari ...

Guide to transforming an IdentityMap<String, dynamic> into a UInt8List

I have a cloud function that generates a JavaScript Buffer object, which looks something like this: functions .region("europe-west2") .runWith({ timeoutSeconds: 20, memory: "128MB", }) .https .onCall(asyn ...

Tips for utilizing a bootstrap navbar and dropdown in conjunction with angular 7

Attempting to click on the Dropdown link in the menu, but nothing happens. <nav class="navbar navbar-expand-lg navbar-light bg-light"> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-a ...

leveraging the default browser behavior for the href and target attributes within an <a> element in Angular 2

How can the behavior of a simple anchor tag in Angular 2 be implemented without being overridden by the routing module? <a href="some url" target="_whatever"> It is crucial to prevent the routing module from highjacking the URL using the base href. ...

Testing of the route.data.subscribe() function using Jasmine

I am currently working on a component that includes two methods. How can I test the ngOnInit() method to ensure that the nameList() method is called with the students parameter? constructor(route: ActivatedRoute, location: Location) { } ngOnInit() { ...

Learn how to employ template expressions in Angular's ng-select to designate a selected value

How can I set the selected value in Angular ng-select using a template? Here is an example: <ng-select [options]="[{label : "first", value : "1"}, {label : "second", value : "2"}]" ** ...

How to Dynamically Enable or Disable a Button in Angular 2 Based on Text Field Values

I am facing a situation where my UI contains multiple text boxes and dropdown fields. My goal is to activate a button on the UI as soon as one of these fields has a value. I have set up a function that is triggered by the ngModel values assigned to these f ...

Observable is delivering each individual letter of the string one at a time

I am encountering an issue with the code I have which involves sending data to Firebase, waiting for a response, and then displaying the result to the user: sendRequest (data): Observable<any> { // Sending data to Firebase const key = this.d ...

Query the Firebase database in Angular2 to locate the latitude and longitude values that are nearest to the user's current coordinates

I am working with a database table named locations, which contains a list of places along with their corresponding lat/long coordinates. Additionally, I am utilizing geolocation to retrieve the user's current lat/long. My goal is to identify the loc ...

How can I utilize a variable to define the key for the template HTML property in Angular 7?

Is there a method in Angular 7+ that allows me to incorporate a variable as the template html property key? I am trying to achieve something like the following: <path [attr.data-**<use-variable-here>**]="edge.id"></path> ...

Guide to transforming plain text into HTML format using Angular 4

In my Angular application, I am facing the task of adding a value to an array where the value itself needs to be in HTML format. This means that when the value is displayed, it should render as HTML text. For instance, if someone hovers over the text, I ...

Ways to stop the MasterComponent from rendering on every route change

I have a dropdown menu: click here to view My goal is to keep the dropdown open when the user opens a menu, but disable it if the user changes routes by clicking on another menu. How can I achieve this? Note: If the user navigates within the same route, ...

I'm puzzled as to why my createDoorMethod is returning a string value instead of a number, even though I am passing it a number. Can someone help me

Currently enrolled in a web development course, I am diving into the world of Angular 2 and TypeScript. Despite following along with the video tutorial and using the same code, my implementation is not working as expected, leaving me puzzled. Here is the ...

When updating data, the cursor in Angular 2 textboxes tends to move to the end of the

I have specific restrictions in the name field that I am attempting to validate using a directive. Within the directive, I am utilizing a regular expression to verify a valid name and then updating the textbox with the valid name using valueAccessor.writeV ...

Add a component to another component in real-time

Check out my StackBlitz demo: DEMO I'm attempting to insert the 'table' component into the #test section of the app component when the visualization type is 'table'. To achieve this, I am using the createTable() function which gen ...

Putting in Angular's most recent version

While attempting to update to the latest version of angular/cli, I encountered an error: npm install --save-dev @angular/cli@latest npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules\chokidar\node_modules\fs ...

Syncfusion Angular TreeGrid Hierarchy connectors and lines for improved data visualization

Is it possible to display guiding lines or connectors that represent the hierarchy of data in a Tree Grid? You can see an example with blue lines in the image below: https://i.sstatic.net/yA8vP.png ...

Implementing the ternary operator on a nested object field in typescript to enforce type validation

Is there an issue with my code or is this intentional? I want to write something similar to this. type MyDefinition = { salutation: string; value?: { typeOfValue: string; val?: string }; }; function create(name: string, input?: Partial<MyDefin ...

Angular 2 Component remains persistent when accessed through parameterized routes

Here is my test route with parameter T1: { path: 'Test/:T1', component: TestComponent }, After routing from 'Test/1' to 'Test/2', I noticed that my TestComponent does not reinitialize. Could this be a problem with th ...

The field 'name' is not recognized on type 'never'

Currently immersing myself in Angular and experimenting with making an API call, but I'm encountering the following error: error TS2339: Property 'name' does not exist on type 'never'. import { Component, OnInit } from '@angu ...