The AngularJS ng-if directive functions on a variable will only function on the

I'm currently working on updating an old codebase that was written in AngularJS, a framework I am not very familiar with. My task is to implement a spinner that appears when an HTTP request is sent and disappears once the response is received.

The spinner's visibility is controlled by the ng-if directive and the $scope.authenticating variable.

At present, when the page loads, the spinner is visible (as per the initial state of $scope.authenticating === false).

When a user triggers the HTTP request by toggling a switch, the $scope.authenticating is set to true and the spinner appears correctly.

However, after the response is received and processed, even though the $scope.authenticating is set back to false, the spinner remains visible and does not disappear as intended.

Any assistance would be greatly appreciated.

Below is the relevant code snippet:

The controller:

  $scope.authenticating = false


  $scope.myfunction = async function (check, change, user) {
    if (someCheck(user)) {
      $scope.modified = true;
      ...
      $scope.authenticating = true
      let res = await AppUserResource.patch(..., ...).$promise;
      console.log('res: ' + JSON.stringify(res))
      $scope.authenticating = false
    }
  }

The corresponding HTML code snippet:

  <div style="margin-top:13px">
    <div ng-if="!authenticating">
      <label class="switch">
        <input id="switch" ng-change="bypassApps(disabledAppsCheckbox, true, user)" ng-model="disabledAppsCheckbox"
               type="checkbox">
        <div class="slider round">
          <div class="slider-text pull-left text-green-table">{{'ON' | translate}}</div>
          <div class="slider-text pull-right text-red-table">{{'OFF' | translate}}</div>
        </div>
      </label>
    </div>
    <div ng-if="authenticating">
      <i class="fa fa-spinner fa-spin"style="font-size:270px;margin-bottom5%; margin-top5%"></i>
    </div>
  </div>

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

Is there a way to use Axios to send several HTTP requests to a URL simultaneously, but pause once a response is received from any one of the requests?

As a beginner in javascript, I am working on writing a script that will use Axios to send multiple HTTP requests to a web server. The server randomly responds to the requests, and I want the script to stop sending requests once it receives a response. This ...

Transitioning from one CSS id to another during page loading

Wondering how to fade in one CSS id on page load and then smoothly transition to another after a few seconds? Here are the ids: #background { background: url("images/am_photography_bg.jpg") no-repeat center -25px fixed; background-size: 100%; ...

Occasional TypeError when receiving JSONP response using jQuery .ajax()

Occasionally, I encounter an error message stating Uncaught TypeError: undefined is not a function when processing the JSONP response from my jQuery .ajax() call. The JSON is returned successfully, but sometimes this error occurs during the reading process ...

404 Response Generated by Express Routes

Exploring the MEAN stack has been a great way for me to expand my knowledge of node and express. Currently, I am working on creating a simple link between two static pages within the app. My routes are set up as follows: //Home route var index = require( ...

Arranging the data in the table by alternating rows using Datatables

I need to organize my data in a way that includes an additional row for descriptive information, but this particular row should not be sorted. It is crucial for understanding the rest of the data, so hiding or showing it is not an option. Is it possible t ...

Synchronize data with Microsoft AJAX using force sync

When working with the Microsoft AJAX framework, I encounter a problem where my AJAX calls are asynchronous when I actually need them to be synchronous. I'm struggling to find a solution for this issue. In addition, I have been having difficulty findi ...

Build error occurred due to the presence of the following error: Module parse failed with an unexpected character ''' (1:0)

I am facing an issue regarding an unexpected character in a node module file. Below is the content of my next.config.js file: /** * @type {import('next').NextConfig} */ const UglifyJsPlugin = require("uglifyjs-webpack-p ...

What is the most effective method for filtering a table using both column-specific and global filters?

Looking for the most efficient way to filter a large chunk of JSON data client-side using a table? Each header has an input filter where users can enter a string to filter that specific property. There is also a global filter for free text search. If you ...

What is the process of retrieving the return value after creating data in Firestore

I have been experimenting with creating data using firestore in the following manner: createData({state}) { return db.collection('items').add({ title: state.title, ingredients: state.ingredients, creat ...

Having trouble grasping the problem with the connection

While I have worked with this type of binding (using knockout.js) in the past without any issues, a new problem has come up today. Specifically: I have a complex view model that consists of "parts" based on a certain process parameter. Although the entire ...

Implement a jQuery DataTable using JSON data retrieved from a Python script

I am attempting to create an HTML table from JSON data that I have generated after retrieving information from a server. The data appears to be correctly formatted, but I am encountering an error with DataTable that says 'CIK' is an unknown para ...

How can Firebase effectively manage multiple URLs for referencing?

I am facing a scenario with multiple users, each with a unique hashId assigned to them that differentiates their URLs. users/hashId/bla/blah The only variation in these URLs is the hashId value. While the client side updates data in firebase, I need to ...

Creating a React component that allows for pagination using data fetched from a

I have a Spring Boot endpoint that retrieves and lists items from a database: @RequestMapping(method = RequestMethod.GET, value = "/task", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> processTask(@Valid TaskSearchP ...

Ensuring Data Integrity with JavaScript Form Validation

Ensure that if text box A is filled in, text box B must also be filled in before submitting. Vice versa, if text box B is filled in, make sure text box A has data as well. Is it possible to loop this check for multiple text boxes? For example, if row A o ...

Guide to sending a similar request as a curl command through a JavaScript file

After reviewing this Stack Overflow post titled "JavaScript post request like a form submit", I came across a similar situation. Currently, I have a curl command that performs as expected: curl -v -X POST -H "application/json" -H "Content-type: applicatio ...

Refresh a single Object Key in React.js

Hey there, I'm currently working on updating book information via a PUT request to my API. My goal is to send only one property at a time, while keeping the rest unchanged. The issue I'm facing is that if I send just one property, the others are ...

import a function from jQuery that has been defined in an external JavaScript file

Whenever I attempt to execute this action, I encounter an error stating that the function is undefined $(function () { function Example(){ Example1(); } Example1(); }); external.js $(function () { function Example1(){ alert("Hello"); } }); ...

Sharing environment variables between a React app and an Express.js server that hosts it as a static site can be achieved by setting

My static site react app is hosted under an express server project in a folder called client/build. The oauth redirect uris point to the express server for token retrieval. The react app redirects users to the oauth endpoint, which is also referenced by th ...

Utilizing AngularJs to input new data entries into a form

I have been exploring AngularJS lately as a beginner and am currently working on creating a form that includes a 'create' button to generate a new server record using a service. Here is the Angular code I have written: $scope.createNewRecord = f ...

Looking to create a drag-and-drop form designer within a web browser - Is AngularJS the optimal framework for this task?

I am in need of developing a web form designer that can be used directly in a browser. Similar to tools like Zoho Creator, proto.io, protoshare, gomockingbird, and lucidcharts. The design will include a tool palette, canvas, and properties box for easy con ...