Struggling to retrieve the value from ng-model?

Currently, I am utilizing this account due to being logged into Facebook on my other account and not having access to my phone for the verification code process.

On another note, I am struggling to retrieve the value from an ng-model despite numerous attempts. I believe a fresh pair of eyes might be able to help me figure it out by quickly reviewing my code. Cheers...

Html:


<div class="form-group"><label class="col-sm-2 control-label">Established :</label>
<div class="col-sm-10"><input type="text" class="form-control" ng-model="established"></div>
</div>                        

<button class="btn btn-primary " style="float:right;" ng-click="saveApprisalDetails()" type="button"><i class="fa fa-paste"></i> Save</button>


Controller:

        $scope.saveApprisalDetails=function(){
    var urlgetappraisals = './dbscripts/getAppraisalsByRef.php?ref=' + ref
    console.log(urlgetappraisals);
    $http({
        method: 'GET',
        url: urlgetappraisals
    }).success(function(data) {

        $scope.appraisaldetails = data;
        console.log(JSON.stringify(data));

    var url = './dbscripts/saveApprisal.php?id=' + data[0].id;
        url += '&appraisalCompany=' + appraisalCompany;
        url += '&title=' + ref;
        url += '&established=' + $scope.established;

 console.log(url);

            $http({
                method: 'GET',
                url: url
            }).success(function(data) {
            })
    })
}
}
catch(e){}
}

Answer №1

Perhaps consider trying a different approach at the start of the controller:

$scope.view_data = {};

Within the function:

url += '&established=' + $scope.vies_data.established;

And within the view:

<input type="text" class="form-control" ng-model="view_data.established">

I hope this suggestion proves to be helpful =)

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

Tips for triggering functions when a user closes the browser or tab in Angular 9

I've exhausted all my research efforts in trying to find a solution that actually works. The problem I am facing is getting two methods from two different services to run when the browser or tab is closed. I attempted using the fetch API, which worke ...

Angular 2 event emitter falling behind schedule

I am currently utilizing Angular 2 beta 6. The custom event I created is not being captured import {Component, OnInit, EventEmitter} from 'angular2/core'; import {NgForm} from 'angular2/common'; import {Output} from "angular2/core" ...

Using console.log() within a method while chaining in JavaScript/jQuery

I've been experimenting with developing jQuery plugins and I'm interested in chaining methods. The jQuery tutorial (found here: https://learn.jquery.com/plugins/basic-plugin-creation/) mentions that you can chain methods by adding return this; at ...

Freezing the website by setting async to false

I've been having issues with my website freezing when using async set to false. I need confirmation before executing the script. $.ajax({ type: "POST", url: url, data: form.serialize(), async: false, success: function(data) { ...

How can I add text to a textbox within a duplicated div using Javascript or Jquery?

I'm looking to add text to a cloned div's text box using jQuery. I have a div with a button and text box, and by cloning it, I want to dynamically insert text into the new div. $(document).ready(function () { $("#click").click(function () { ...

Refresh the angular list filter by clicking on it

I'm struggling with updating an Angular list after the filter is changed. Below is the HTML code I am using: <li ng-repeat="items in list | filter:filterList" style="list-style-type:none"> {{items}} </li> Additionally, here is the o ...

Is there a way to immobilize an object in JavaScript without resorting to Object.freeze()?

Is there a way to freeze the following object without relying on Object.freeze()? Let's find out: const obj = { a:'test', b:'Something' } ...

Utilizing VueJS to Establish a Binding Relationship with Props

One of my Vue components is named Avatar.vue, and it is used to create an avatar image based on user-defined props. The parameter imgType determines whether the image should have rounded corners or not. Here is the code: <template> <div> & ...

Difficulty arises when trying to add various text fields to a collection

Lately, I've been making modifications to the Meteor1.3+React Todos app to familiarize myself with the basics, and I must say, it's been a smooth ride so far. However, I have encountered a roadblock. I want to incorporate an additional text field ...

The integration of Node.js and Socket.io with Phaser.js is experiencing difficulty when connecting to socket.io with the parameters "?EIO=3&transport

My node.js server is up and running, and my phaser.js game is functioning as expected. However, I am facing an issue where the 'connected' console log is not displaying when the game runs. Instead, I am receiving this error message on the client ...

Create a page turning effect in React that simulates scrolling a certain amount at a time

Is there a way to disable default scrolling and have the page automatically scroll to the next item? For example, if I have element2 below element1, how can I set it up so that when I scroll down once, the page scrolls directly to the position of element2 ...

React | Utilizing ForwardedRefs with React Components

I'm currently working on a React project where I am creating a custom component that needs to be exported using forwardedRef. However, as I attempt to do this, an error keeps popping up: error This is the code snippet causing the issue: export inter ...

The video does not begin playing automatically after utilizing react-snap

I included a background video in my react app that auto-plays upon page load and functions perfectly. Here is the JSX code I used: <video autoPlay loop style={{ backgroundImage: `url(${topVideoImage})`, }} muted playsInl ...

What is causing the label's color to remain the same?

Once the page has loaded, the label color (which reads "enter your name") is supposed to change to red. However, despite the script being in place, the color remains unchanged. What could be the reason for this? SCRIPT window.onload = initiateScript; fu ...

AngularJS is throwing an error of "TypeError: Cannot read property 'then' of undefined."

Within an AngularJS project, I am aiming to retrieve user data from those who sign in and utilize this data within an HTML form. To achieve this, I have a script called sessionService.js that sends requests to the server and receives responses. The follow ...

Tips for resolving issues with mysql_fetch_assoc()

Similar Question: mysql_fetch_array() error - Fixing parameter issue Whenever I execute the code below, I encounter this issue: Warning: mysql_fetch_assoc(): provided argument is not a valid MySQL result resource If anyone knows how to rectify this pro ...

Issue encountered while trying to access PHP script within table data utilizing Ajax

I have a small project that involves displaying different news articles. I need to incorporate the news_all.php file into the table data in dashboard.php without using the include('news.php) function. Instead, I am utilizing Ajax methods to achieve th ...

What is causing the consistent occurrences of receiving false in Angular?

findUser(id:number):boolean{ var bool :boolean =false this.companyService.query().subscribe((result)=>{ for (let i = 0; i < result.json.length; i++) { try { if( id == result.json[i].user.id) ...

Discovering a way to retrieve objects from an array of objects with matching IDs

Here is a code snippet I put together to illustrate my objective. arr = [ { id:1 , name:'a', title: 'qmummbw' }, { id:2 , name:'b', title: 'sdmus' }, { id:2 , name:'', title: 'dvfv' }, ...

An error notification received from the command "jspm install jquery"

As I follow the tutorial on the jspm.io site, everything goes smoothly until I reach step 3. When I try to execute jspm install jquery, an error message pops up. The error reads: warn Error on getOverride for jspm:github, retrying (2). ReferenceError: ui ...