Form remains unchanged after manipulation in callback

Currently, I have a form with a list of editable objects (constants). Previously, it was possible to delete any object without confirmation. Now, I want to add a ngBootbox confirm step before the deletion process.

In my .ts file, the code for deleting an object is as follows:

public DeleteMyObject(constantName: string): void {

               DeleteConstant(constantName);
               this.ConstantsNavigationForm.$setDirty();

            }

The view:

<ng-form name="Vm.SoftSensorDialogComponent().ConstantsForm">
    <ng-form class="st-table-container" name="Vm.SoftSensorDialogComponent().ConstantsNavigationForm">

        <button type='button' "
                ng-click="Vm.SoftSensorDialogComponent().SoftSensorDialogConstants.DeleteSoftSensorConstant(dataItem.Name)"></button>

    </ng-form>

</ng-form>

Deleting an object now updates the form immediately.

I have added an additional step in my .ts file:

public Request_DeleteConstant(constantName: string) {

            let options = {
                message: "<h4>Are you sure you want to delete :" + constantName + " ?</h4>",
                buttons: {
                    cancel: {
                        label: "CANCEL",
                        className: ""
                    },
                    confirm: {
                        label: "OK",
                        className: "",
                        callback: () => {
                            this.DeleteConstant(constantName);
                        }
                    }
                }
            };

            this.softSensorDialog.$ngBootbox.customDialog(options);
        }

Now, a bootbox confirmation dialog appears before deleting an object. However, the form is not updated after a successful operation. It seems to be related to the callback function. Is there a way to manually refresh or update the form?

Answer №1

Issue: Executing the delete operation through callback resulted in the loss of context.

Resolution: To resolve this issue, ensure to pass the context $scope and invoke $scope.apply() within the callback function.

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

Exploring the process of how Spring MVC's DeferredResult is transmitted back to an AngularJS client

Having little experience with Spring MVC and AngularJS, I am working on an application that synchronizes selected tables from two database instances. When the synchronization process is triggered, a specific service is called at the server end: @RequestMa ...

Calling a function within another function is not allowed in Typescript

Essentially, I have an Angular Web Page that uploads a file to the server via a POST request, which is then received by my NodeJS app. The issue arises when attempting to retrieve the file path in subirArchivo() and pass it to a function called InsertaPer ...

Tips for using multiple Angular directive modules in PprodWant to enhance your Pprod experience by

Currently, I am working on jhipster Release 0.7.0 and our jhipster app has multiple types of directive modules – one for the index page and another for common directives. However, when we run the app on Prod profile, an exception occurs: [31mPhantomJ ...

Default parameters for the ngMessages directive

I am looking for a way to make modifications to AngularJS Material inputs without having to create a new directive or add attributes everywhere. Is there a way to parameterize all ngMessages directives without the need to add them individually? <md-inp ...

Transfer information from one Angular JS page to another pager based on ID

In my use of the mobile angular js UI framework, I am a beginner in angular js and looking to transmit data from one page to another using city id. When a user clicks on a city, the data should be displayed according to that specific city. HOME PAGE: ht ...

Encountering challenges while transitioning from ngrx version 2 to version 4, specifically related to typing in array de-structuring

The error indicates a missing comma after the action parameter in the .map. Another error pops up when hovering over DataActions.AddDataAction, displaying Tuple type '[Action, AppStore]' with length '2' cannot be assigned to tuple with ...

Adjusting the timing of a scheduled meeting

Is there a way for me to update the time of a Subject within my service? I'm considering abstracting this function into a service: date: Date; setTime(hours: number, mins: number, secs: number): void { this.date.setHours(hours); this.date.s ...

Tips for utilizing a personalized design with the sort-imports add-on in VS Code?

After recently installing the VS Code extension sort-imports, I decided to give a custom style called import-sort-style-module-alias a try. Following what seemed to be the installation instructions (via npm i import-sort-style-module-alias) and updating m ...

"Error message: TypeORM DataSource encounters a password issue with the client

Here is the content of my data-source.ts file: import {DataSource} from "typeorm"; import path from "path"; import {User} from "./entity/User"; import { config } from "dotenv"; config(); export const AppDataSource ...

Place the menu within the image, positioned at the bottom

Could someone help me with placing a menu at the bottom of an image using HTML, CSS and Bootstrap 4? I have limited CSS knowledge and need assistance. Currently, my navbar is located below the image but not within it like this: I am looking to achieve so ...

Tips for troubleshooting ImageArray loading issues in AngularJS

Having some trouble learning Angular and getting stuck with this Image array. Can someone please help me understand what's wrong with my code and how to fix it? FilterAndImages.html <!DOCTYPE html> <html ng-app="store"> <head> < ...

The custom service is failing to load, in the simplest terms possible

After creating a dataService.j that contains the following: angular.module('dataService', []) .service('gameDataService', function() { var _gameData = { loggedIn: "false", gameJoined:"false", tableFu ...

Tips for displaying "in progress" in AngularJS when data loading is slow

I am experiencing sluggish loading times with my ng-repeat function in AngularJS. This is causing my browser to freeze up. How can I implement a loading animation or indicator to show the user that the data is still being loaded? ...

Creating a copy-paste functionality in my table by utilizing an Angularjs directive

I am currently working on a table where I need to enable the ability to copy data from one cell and paste it into another. I understand that I will need to utilize an event listener like element.on('ctrl-c',function(e){ $scope.textToBeCopied = ...

the Sprite fails to appear on the screen

Can you help me figure out how to fix the issue I'm having with loading images in this component? Currently, when I refresh the page, the image does not load properly and appears resized to 1 pixel width. Should I wait for the image to fully load befo ...

Employing the Eclipse Palantir TypeScript Plug-in in conjunction with JSPM

I currently utilize the Palantir Eclipse TypeScript Plug-in (v1.8.0.v20160223-1645), which functions flawlessly when my d.ts files are stored in the same source folder /src. However, due to JSPM, these files reside in a different folder now, causing issues ...

Tips for activating automatic building of packages when utilizing pnpm install?

Our unique project is utilizing a combination of pnpm, workspace, and typescript in adherence to the monorepo standard. Upon cloning the repository, we execute a pnpm install command to download dependencies and establish links between local packages. De ...

What is the solution to fixing a 400 bad request error in Angular Routing?

Encountering an issue on a particular route where a 400 error is displayed in the screenshot every now and then. It seems to work fine for a few minutes after deleting cookies, but the error resurfaces after accessing it multiple times. Other routes are fu ...

Validating radio button groups within an ng-repeat in Angular

Currently, I am facing a challenge in implementing radio button group validation within angular's ng-repeat structure. Here is the HTML snippet: <div ng-repeat="driver in drivers"> <input required type="radio" value="M" name="driverGender ...

Integrating Braintree with Angular for accepting Android Pay transactions

Currently facing a challenge with Braintree that I need help resolving. I have successfully set up Braintree to generate my client_token using my API, and created the drop-in feature as a test. Here is how I implemented it: (function () { 'use st ...