AngularJS is used to get the number from the input

I need to display the value of $scope.value in the console.log after clicking the input field where I have selected a number.

Here is my code:

<table class="table table-bordered table-striped">
                        <thead>
                        <tr>
                            <th >Name
                            <th >System
                            </th>
                            <th>Actions</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="n in data">
                            <td style ="word-break:break-all;">{{n.name}}</td>

                            <td style="width:35px;">{{n.system}}</td>
                            <td><input class="form-control input-sm" type="number" name="input" ng-model="value"
                                       min="0" max="100" style="width:55px;">
                                </td>

                        </tr>
                        </tbody>
                    </table>
                    <button ng-click="postapi()">Value</button>

Check out this Plunker for reference: http://plnkr.co/edit/g1t4pludTTIAJYKTToCK?p=preview

Thank you in advance for any help!

Answer №1

The value defined inside the ng-repeat cannot be accessed because each ng-repeat creates its own scope, making it impossible to access a child scope from a parent scope.

To solve this issue, consider changing ng-model="value" to ng-model="n.value". This way, you will be able to access the value within the object.

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

Div scrolling allows for parallel viewing of PDFs in a side by side arrangement

I have two scrollable elements on my webpage: one positioned on the left side and the other on the right side. The left element is a regular div, while the right element is an object containing an embedded PDF. <object width="100%" height=&quo ...

What could be the reason for the scope value not being set during testing?

I've developed a unit test for my Angular 1.4.4 directive: angular.module('myApp', []) .directive('uiList', [ function() { return { scope: { lengthModel: '=uiList&ap ...

Maintain the UI actions and status using angular-ui-router

Is it possible to maintain the UI state in angular-ui-router similar to how native apps do? For instance, if I expand an accordion list on the home view, then navigate to another view by clicking on an item within that list, can the accordion still be expa ...

Issue with uploading an Excel file via REST: The POI library refuses the file due to a problem with the

I am facing an issue while attempting to upload an excel (.xlsx) file using AngularJS and REST (Jersey). The multipart boundary is being added to the file received in REST, causing the apache POI Library to reject it as an invalid file with the following e ...

Retrieving the latest state within a callback function

We are utilizing a third-party library (over which we have limited control) that requires a callback as an argument to a function. Is there a correct way to provide this callback with the most up-to-date state? In class components, this process is typicall ...

What is the mechanism behind the jQuery ready function that enables its first parameter to transform into a jQuery object?

While browsing today, I came across this interesting code snippet: jQuery(document).ready(function($$){ console.log($$); }); It seems that $$ is recognized as the jQuery object itself. Typically, to achieve this, we would need to pass the jQuery varia ...

Error: Vue is unable to access the property '_modulesNamespaceMap' because it is undefined

I've been working on a simple web app to enhance my testing skills in Vue using Vue Test Utils and Jest. However, I encountered an error related to Vue while trying to console log and check if AddDialog is present in my Home file. The error message I ...

Can you explain the compatibility between comet and PHP?

As I utilize Comet iframe, I simply send script tags from the backend PHP file to the frontend where JavaScript displays them. I would appreciate it if someone could provide a concise explanation of how the comet server fits into the equation and how comm ...

After clicking multiple times within the modal, the modal popup begins to shift towards the left side

I successfully implemented a modal popup in my project, but encountered an issue where the popup moves to the left side if clicked multiple times. Despite searching extensively online, I have not been able to find a solution to this problem. Below is the ...

Angular: Leveraging real-time data updates to populate an Angular Material Table by subscribing to a dynamic data variable in a service

Seeking guidance on how to set up a subscription to a dynamic variable (searchData - representing search results) for use as a data source in an Angular Material Table. I have a table-datasource.ts file where I want to subscribe to the search results from ...

The MVC6 controller is receiving null values for the posted data

I'm currently in the process of migrating my web application from MVC5 to MVC6. While this function worked smoothly in MVC5, it's experiencing issues in MVC6. When I use AngularJS to post data to this WebAPI method, the search parameter always c ...

Having trouble displaying the Primevue dialog modal in Vue 3?

I am using [email protected] and [email protected] Main script import { createApp } from 'vue' import App from './App.vue' import router from './router' import PrimeVue from 'primevue/config'; import &apos ...

Why does the <select> dropdown flash when I select it?

Currently utilizing Angular 1.3 and Bootstrap 3.3.x CSS without the JS functionality. There is also an interesting animated GIF embedded within. <div class="form-group"> <div class="col-lg-3"> <label clas ...

What is the best way to retrieve the value of the chosen item from an igcombo selection?

I am looking to retrieve the value of the selected item from igcombo in order to use it within an if statement that will determine whether to show or hide a panel. function ObtainSelectedValue() { var filterJSON = {}; filterJSON.SVC_FEE_TYPE_ID = $( ...

Dealing with reactive form controls using HTML select elements

I am working with a template that looks like this: <form [formGroup]="form"> <mdl-textfield type="text" #userFirstName name="lastName" label="{{'FIRSTNAME' | translate}}" pattern="[A-Z,a-zéè]*" error-msg ...

Fixing TypeError: Object #<IncomingMessage> has no method 'flash' in ExpressJS version 4.2

Currently, I am utilizing ExpressJS 4.2 and PassportJS for authenticating local users. Everything seems to be working smoothly except for when attempting to display a failureFlash message. Below is my configuration setup, thank you in advance! ==== Necess ...

How can I pass a value back to a koa generator function?

I currently have a setup similar to the following: var app = koa; var run = function (generator){ var it = generator(go); function go(err, res) { it.next(res); } go(); } app.use(function *() { run(function *(callback) { var res ...

JavaScript - undefined results when trying to map an array of objects

In the process of passing an object from a function containing an array named arrCombined, I encountered a challenge with converting strings into integers. The goal is to map and remove these strings from an object titled results so they can be converted i ...

How can you use jQuery.ajax to solely fetch the status code without downloading the entire document?

My application relies on the use of jQuery.ajax to check if a particular resource exists by constantly polling it. Once the resource is no longer returning a 404 status code, the app redirects to view that resource. However, I am concerned about downloadin ...

Conceptual Confusion

Create a unique function using the array provided below to find and store the longest name. Then, save that name in a variable called longest_name and print it out using another variable named answer. let array = [ "John", "Lee", "Smitty", "Cyren", "Linda" ...