Reload the Angular application and navigate to a different state

Introduction

In my extensive angular application, there are numerous forms for various items.

These forms are associated with action objects that have unique schemaforms.

The dropdowns in these forms vary based on the specific action and its parent company.

Previously, the dropdown contents were not updating without a page reload.

Key Concern

How can I trigger a window reload followed by a state.go change?

Code Snippet

  $scope.goToActionWizardFull = function(CUuid, AUuid) {
    $window.location.reload();
    $state.go('actionWizard', { companyUuid: CUuid, uuid: AUuid });
  }

Current Issue

This code is intended to clear the previous schema data from cookies/local storage to display the correct dropdown contents for the current action. Then, it should navigate to the new action's page.

However, instead of performing as expected, this code redirects users to the actionWizard page then back to the company page.

Additional Information

The dropdown content is fetched from sharedVars file:

.controller('ActionController', function ($scope, $stateParams, $state, $window, sharedVars, Company, Action) {

Accessed here:

$scope.actionSchema = sharedVars.getActionSchema();

Modified here:

$scope.actionSchema.properties.RDAInput.items.properties.input_location.enum = $scope.actionSchema.properties.RDAInput.items.properties.input_location.enum.concat(eachRDSchemaProperty['name'])

Subsequently, the form is loaded.

All of this utilizes

Update 2

Complete HTML form snippet:

<form sf-schema="actionSchema" sf-form="actionForm" sf-model="actionModel" name="submittableActionForm">
</form>

Update 3

Details from my bower.json file:

{
  "name": "isp",
  "appPath": "src/main/web",
  "moduleName": "ispApp",
  "version": "0.0.1",
  "dependencies": {
    "jquery": "2.1.1",
    "angular": "1.6.1",
    ...
...

Latest Update

I have posted a related query on Stack Overflow that delves deeper into this issue: Reload a pages cache, then go to a new page

Answer №1

In this solution, the script uses the $window object to trigger a page reload when entering the action page. To prevent recursion, it employs a hash.

    var currentHref = $window.location.href
    if (!currentHref.includes("refresh")) {
        $window.location.href = $window.location.href + "#refresh"
        $window.location.reload(true);
    }

Further explanation

This code is designed to perform a complete refresh following a redirect. It executes upon arrival at the new page.

Initially, the URL lacks 'refresh', so the $window.location.href is modified to include 'refresh'. However, only the subsequent line triggers the actual page reload and cache clearance. The reload occurs only after appending the hash.

Through this method, a full reload is achieved without encountering an infinite loop that would typically occur when entering the page automatically.

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

What is the correct way to implement Axios interceptor in TypeScript?

I have implemented an axios interceptor: instance.interceptors.response.use(async (response) => { return response.data; }, (err) => { return Promise.reject(err); }); This interceptor retrieves the data property from the response. The re ...

Getting just the main nodes from Firebase using Angularfire

I'm having trouble figuring out how to print just the parent element names from the structure of my database. The image provided shows the layout, but I can't seem to isolate the parent elements successfully. ...

"Pair of forms and buttons to enhance user experience with Bootstrap and

Experiencing an issue with my webpage that is built using HTML, Bootstrap, and PHP. The page contains two forms: a contact form and a distribution form within a modal. The problem lies within the distribution form as clicking the button only submits the ...

Enhancing ng-model by clicking on a list item

I currently have a textbox on my webpage. <input ng-model="meetingData.client.ClientName" id='txtClient' placeholder="Add new client" type="text"> along with a list of items that I want to interact with. Is there a ...

From creating a simple jQuery fiddle, let's delve into the world

Here is a code snippet I'm trying to transition from jQuery to an Angular directive. Visit this link to view the original code: http://jsfiddle.net/rhtr1w04/ Below is my implementation in app.js: angular.module('app',[]).directive('an ...

Showcase -solely one property object- from numerous property objects enclosed within an array

Hello, I am seeking assistance as I have recently begun learning about angularJS. I am working with objects that have keys such as: scope.eventList=[]; for(){ var event = { id : hash, ...

Creating PNG images in a scripting language for web applications

Imagine giving your website user the ability to specify a radius size, let's say 5px, and in return receiving a PNG file with a circle of that radius. This question can be divided into two sections: In what language and using which technologies can ...

The class "pagination pagination-lg" from the link https://angular-ui.github.io/bootstrap/#/pagination seems to be malfunctioning in Bootstrap 4

Just starting out with angularjs and I'm trying to implement pagination using https://angular-ui.github.io/bootstrap/#/pagination. However, I'm facing an issue where the style class "pagination pagination-lg" is not applying properly. I'm cu ...

Utilize AngularJS to convert datetime into decimal format

Can you help me understand how to convert a decimal number to a date in AngularJS? Here's an example: Source: 20150911141804 Expected Format: 2015-09-11 I'm trying to format this source number within a cellTemplate in ui-grid. Thank you! ...

rearranging the sequence of buttons using JavaScript

I am faced with the challenge of making a series of buttons draggable and droppable within a parent div without using any external libraries at the request of the client. Although I could have easily accomplished this task with jQuery, it's an opportu ...

Launch the game within the gaming application

I am looking to incorporate a game within another game... Here's what I mean: Open the app: Pandachii Next, navigate to the 4th button (game pad). When we click on the game icon, I want to launch another game (located below the Pandachii window - c ...

Unable to utilize Stats.js with @angular/cli version 1.4.4

Attempting to utilize @types/stats with @angular/cli following the guidance at https://github.com/angular/angular-cli/wiki/stories-third-party-lib. However, encountering a tslint error when trying to import * as STATS from 'stats.js'. [ts] Modul ...

Error: ajax is not defined and needs to be declared (repeated twice)

Currently, I have a form that requires processing using Ajax. <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> <div class="column1"> <form class="form box" action="javascript:networkCheck();" ...

Ways to avoid scrolling on a fixed element

Here is the HTML setup I have... body .top .content The issue I am facing is that when scrolling reaches the end of the ul in the .top element, the background starts to scroll. This can be quite disorienting and makes the site slow on tablets. Even ...

Working with JSON structure using Javascript

I successfully transformed an XML file into a JSON format, but now I need to manipulate the data in order to achieve a specific desired structure. Here is the Original format { "machine": "Hassia2", "actual_product_date": "08/24/2017", "holdi ...

Creating routes in JavaScript to split an object like a tree: a comprehensive guide

When I receive a set of filters as a composed object in my express server, I realized that to create the query I need to split each object route into a separate array of keys. For example: $and: { age: [21, 22], name: { $like: "Alice& ...

Issue encountered during Heroku deployment: Failed to build React app. When attempting to push changes to Heroku, an unexpected end of input error was received instead of the expected result. This error occurred on an unidentified file at

Encountering a parsing error while attempting to deploy a React app on Heroku using git push heroku master. The app built successfully yesterday, but since then some media queries were added by another contributor to various .scss files. The primary error ...

execute a series of asynchronous functions one after another

async function cancelUserSubscriptionHandler() { const unsubscribe = await fetch("/api/stripe-sessions/cancel-subscription", { method: "PATCH", body: JSON.stringify(), headers: { "Content-Type": "appli ...

ng-view is the culprit behind the website's fatal error

Encountering a "RangeError: Maximum call stack size exceeded" in the console while trying to recreate a basic routing example from w3schools. The crash seems to be linked to <div ng-view></div> in index.html. Despite making minimal changes from ...

Unable to bring in the specified export 'Directive' from a non-EcmaScript module - only the default export is accessible

I am currently working on an ionic angular project and utilizing the ng-lazyload-image plugin. However, I am encountering errors during compilation that look like this: Error: ./node_modules/ng-lazyload-image/fesm2015/ng-lazyload-image.mjs 401:10-19 Can ...