Drop down menu not populating with options

I'm trying to automatically bind the second value in a select drop-down menu that I've created using a list of numbers ranging from 0.01 to 10.

                
getNumbers();
function getNumbers() {
    $scope.numbersArray = [];
    for (var j = 1, i = 0.01; i <= 10; i += 0.01, j++) {

        var newArray = {
            id: j,
            value: i
        }
        $scope.numbersArray.push(newArray);

    }
}

Below is the select dropdown I have set up:


<select ng-model="test.info" class="form-control" ng-options="r.id as r.value for r  in numbersArray" tabindex="1">
    <option value="">--Select--</option>
</select> 

Answer №1

To assign the second element in the array to your model in the controller, you need to specifically set it equal to that element.

$scope.test.info = $scope.numbersArray[1];

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

What is the best way to properly pass parameters?

const root = { user: (id) => { console.log("returning object " + JSON.stringify(id.id) + " " + JSON.stringify(storage.select("users", id.id))) return storage.select("users", id.id) } } Struggling to correctly pass the parameter ...

Dynamic row additions causing vanishing rows in the table due to JS/jQuery implementation

I am currently facing an issue while trying to create a table where I can add rows dynamically. Despite looking at various solutions on this topic, none of them seem to resolve the problem I am encountering. The newly added rows disappear immediately after ...

Is there a way to dynamically enable ui-sref through element.append in Angular?

I am in the process of developing a pagination directive. Once the total_for_pagination data is filled, the appropriate HTML for the pagination gets generated. Here's my current HTML structure with a maximum of 50 per page: <pagination data-numbe ...

Troubleshooting Autocomplete User Interface Problems

I am currently working on a website user interface and I have encountered an issue specifically in IE7. When searching for a company, the display is not showing up correctly, as demonstrated in the image below. This problem only occurs in IE7, it works fi ...

Exploring the Adjustment of State as well as Function in Next/React JS

I'm facing a challenge in my React project where I need to manage state and trigger a function across separate component files. Specifically, I have my main app file along with two components (header and sidebar) stored in the components folder. The h ...

I need to know the right way to send a file encoded in Windows-1255 using Express

I'm currently developing an API that is responsible for generating text files. The purpose of this API is to support legacy software that specifically requires the use of Windows 1255 encoding for these files. To create the content of the file, I am r ...

When attempting to access injected services from the effect(), they appear to be empty

Upon receiving a notification, represented as a signal object, I utilize a facade service that not only returns the object but also includes a variety of methods. When new data is received, I analyze within the constructor using an effect whether the noti ...

Steps to incorporate a nested table in HTML with merged columns

A number of university groups have utilized my HTML table applications. Each university may have various groups, with each group currently consisting of only one student. The HTML code I am working with includes AngularJS as shown below: <table&g ...

Adjust the header as the user scrolls

Having a little issue with my header. I'm new to Bootstrap and would like to change my header when scrolling down. Everything works perfectly, but when I reload the page, the header remains in the "scrolling state". Apologies for any language mistakes ...

Retrieve data from a JSON file using Ajax and jQuery

I have a JSon file that contains information about some matches: [{ "id": "2719986", "orario": "00:30", "casa": "Bahia", "trasferta": "Internacional" } , { "id": "2719991", "orario": "02:00", "casa": "Palmeiras", "trasferta": "Botafogo RJ" }] I'v ...

SyntaxError: The token + was not anticipated

I encountered an error while using this code even though the php id variable is properly set. Why am I receiving the unexpected token error? var current_page = 1; var id = <?php echo $id; ?>; $(document).ready(function(){ $.ajax({ &apos ...

Encountering an error stating that 'coordinates should consist of an array with two or more positions'

Utilizing turf.js to generate a line depicting the path of an individual while their location is tracked. An array of coordinate arrays resembling Turf.js (lineString) is causing this error: Uncaught Error: coordinates must be an array of two or more posi ...

The Material UI library is signaling that there is an unidentified property called `selectable` being used with the <table> tag

Whenever I try to add the selectable attribute to the Table component in Material-UI using React JS, I encounter an error. Despite checking that selectable is indeed included in TableProps, the issue persists. List of Dependencies : "material-ui": "1.0.0 ...

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 ...

One module triggers nodeMailer to send an email, while the other does not request it

My website needs to send two different types of emails: One type is a randomly generated password sent to a user who requests it (from the PayAsYouLike module). The other type is a 'get-in-touch' form that sends the email to my personal account ...

After the update to the page, the DOM retains the previous element

I'm currently developing a Chrome Extension (no prior knowledge needed for this inquiry...) and I have encountered an issue. Whenever I navigate to a page with a specific domain, a script is executed. This script simply retrieves the value of the attr ...

Vue3 and Ionic combined to create a Component that became a reactive object in Vue

Vue is issuing a warning about receiving a Component as a reactive object, which can cause unnecessary performance overhead. The warning suggests using markRaw or shallowRef instead of ref to avoid this issue. However, in my code, I am not explicitly using ...

Steps for choosing a row from a dynamic table when clicking the mouse

Is there a way to retrieve a row's value upon mouse click or by checking the checkbox in the provided HTML table? Below is the JavaScript code for fetching values from a table using Spry, sourced from an XML file: var ds1 = new Spry.Data.XMLDataSet( ...

Fetching data using Axios from a specified URL

I am currently facing an issue with the npm package axios while attempting to execute a get request to a specific URL. The problem arises as I consistently receive an error code 503. Here is the snippet of code in question: let data, response; response = ...

Converting UTF-16 to UTF-8 in JavaScript: A step-by-step guide

I'm facing a challenge with Base64 encoded data in UTF-16 format. While most libraries only support UTF-8, I need to find a way to decode the data by dropping the null bytes, although I'm not sure how to go about it. Currently, I'm utilizin ...