Refreshing the View based on ng-model modifications in AngularJS

Is there a way to update an array linked to my ng-model after clicking a button without having to bind them? The issue arises because the data is being selected from a list. I want the data to be updated as soon as the button is clicked, without needing to change views or refresh the page.

Below is my HTML code, showing where the ng-model text should be updated:

'<span>HVACs: <ct-input  disabled="true"  ng-model="data.groupLimits[activeIndex].devices"  </ct-input> </span>' + '<br>' +
'<span> Add/Remove Device: <ct-input-list list="hvacsList"  ng-model="model"   </ct-input-list>' + '</span>' +
+ '<ct-button text="Add Device" show="true" ng-click="addDevice()"> </ct-button>' 

Answer №1

When initially loading the array from a controller method call, simply execute that method again after completing any other tasks, for example:

In the controller:

$scope.LoadModel = function(){
    myService.loadModel(id).then(function(d){
        bindArrayToModel();
    })
}

$scope.DoClick=function(){
// do something
 $scope.LoadModel();   // reload model here
}

In the view:

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

Angular image source load test encountered an error

<div class="col-xs-4 col-sm-4 col-md-4"> {{jsonData[current].profilepic}} <div ng-if=IsValidImageUrl(jsonData[current].profilepic)> <img id="pic" ng-src="{{jsonData[current].profilepic}}" alt=""/> </div> < ...

Automatically submitting an HTML form from a JSP page

Encountering the same origin policy issue with Ajax, but in need of sending a form post to a different server. The question at hand is: How can I call my JSP to automatically submit a form to another server? Attempts to use an AJAX call to the JSP page h ...

"Troubleshooting issue with jQuery failing to identify PHP variable within an if

I have managed to implement a code that utilizes jQuery and PHP session to add items to the cart. Everything is working smoothly except for displaying the status of the action, such as "Added to cart" or "Updated". The message about the status is stored in ...

The issue with line chart ticks not functioning properly in angularjs-nvd3-directives

I am currently utilizing cmaurer's nvd3 directives in combination with angularjs, which can be accessed here My aim is to modify the x-axis ticks count to include 3 (start, middle, end dates), however, I have encountered issues with the nvd3 ticks pr ...

What is the best way to ascertain if a specific string is included in the URL of another frame on my website?

On my website, there is a parent page containing two iframes. Everything is set up as I want it, except for one issue when using the browser's back button - only one of the iframes updates its content. I am attempting to implement a check within the c ...

Prevent the use of exponential notation with double numbers in GWT

Is there a way to remove the exponent from a double on the client side in GWT? public double evaluate(final double leftOperand, final double rightOperand) { Double rtnValue = new Double(leftOperand * rightOperand); //Need code to remove expone ...

Add a tab character within a textarea

How can I add a tab character (indent) inside a textarea using AngularJS? I attempted this approach: <textarea class="form-control" rows="10" ng-model="vm.text" ng-keydown="vm.handleTabKey($event)"></textarea> Here is the handleTabKey functi ...

Showcase the Uploaded Image Section within the Dropzone Display

https://i.sstatic.net/xzJWT.png Hello! I am currently working on implementing Dropzone.js to create a gallery. I've encountered a small issue where the default behavior of Dropzone displays a blank container area with a clickable effect to upload pho ...

Uh-oh! Angular 6 has encountered an unexpected error with template parsing

I am currently working on an Angular application where I have integrated the FormsModule from '@angular/forms' in my app.module.ts. However, despite this, I keep encountering the error message No provider for ControlContainer. Error log: Uncaug ...

I am looking to use jQuery to update certain elements on the Cart details page to give it

I'm facing an issue with updating the page properly after clicking Remove from Cart. The item is removed from the cart table, but it still appears on the screen. I need a command to partially refresh the screen after executing my jQuery. Thank you f ...

Concealing overflow for text content through CSS styling

I am currently working with an element that contains both an image and text. View the Fiddle here Note: To see the full grid, resize the preview accordingly. The CSS I have written is as follows: .gridster .gs-w .item{ position: relative; wi ...

What is the best way to retrieve data from the state in react components?

After fetching data from my API using a getAll call, I stored all the values in this.state. However, I am struggling with extracting the arrays or objects from my state. Specifically, I am interested in retrieving the 'id' field from: 0: {id: 1, ...

Most effective method for sending information from an HTTP server to a browser client

What is the most effective method for transferring data from the server side to the client when the client is a web browser? The server side is developed in Java, while the client side uses HTML, JavaScript, and AJAX. The communication protocol being uti ...

Updating the database table using javascript

I am looking to dynamically update my database based on a condition in JavaScript. Currently, I have been using the following approach: <a href="#" onclick="hello()">Update me</a> <script> function hello(smthing) { if(smthing == true) ...

What is the best way to remove an entire span element that contains contenteditable spans within it?

The issue I'm facing involves a contenteditable div. Inside, there is a span for a 'fraction', following guidance from this source. Below is my current code snippet: <span style="display:inline-block; vertical-align:middle;" contentedita ...

React button synchronization issue with start stop functionality

My React timer module has one input field and three buttons: Start (to begin the timer), Pause (to temporarily stop the timer), and Stop (to completely halt the timer). The issue I am encountering is that when I input a value, start the timer, then press t ...

Changing the Style of a CSS Module Using JavaScript

Embarking on a journey into Javascript and React, I am currently working on my first React app. My aim is to adjust the number of "gridTemplateRows" displayed on the screen using a variable that will be updated based on data. Right now, it's hardcode ...

Inform the PHP backend that the browser has been closed by the frontend Angular application

Currently, I am working on an Angular project that is interacting with a backend project created using PHP and ZF3. I am trying to figure out the most efficient method of informing the backend project when the user closes the browser window. Initially, I ...

Angular html5 mode failing to serve index.html via Express

When attempting to implement html5 mode in my Angular JS app for better SEO, I encountered a challenge with Express serving index.html upon request. This resulted in deep linking issues and the inability to refresh the page. This is how my App.js is curre ...

When using .animate() to set the position, it takes precedence over manually assigning

I'm facing an issue with constantly scrolling objects on the screen, each assigned a number. When you press one of their numbers, it should move far left off the screen and then scroll back on. However, when I try to reassign the position of the eleme ...