Retrieve the dropdown value that matches the label

How can I ensure that the value of a dropdown option matches its label? Currently, when getting options from a JSON file and populating the dropdown, the values do not match the labels. For example, how can I set the value to be "4.90a-ea02" when the label is also "4.90a-ea02"?

<select name="version" class="form-control" ng-model="myObj.Version" 
                  ng-options="item as item.version for item in contver| unique:'version'|orderBy: '-version'" >

https://i.sstatic.net/WFuYe.png

Answer №1

<select name="versionSelect" class="form-control" ng-model="myObj.SelectedVersion" 
                  ng-options="item.version as item.version for item in contver| unique:'version'|orderBy: '-version'" >

Answer №2

All you need to do is update the

ng-options="item as item.version for
to
ng-options="item.version as item.version for

<select name="version" class="form-control" ng-model="myObj.Version" 
  ng-options="item.version as item.version for item in contver| unique:'version'|orderBy: '-version'" >

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

Issue with Angular ng-Model not appearing on the second attempt

Within a modal popup that appears based on certain conditions, everything functions normally the first time it is displayed. The code in question is as follows: <div class="form-group"> <p>First Name:</p> {{vm.user.name_first}} ...

Error encountered: jquery form validation fails to register changes

I am currently developing a calculator-like code where users will submit a form multiple times, and I need to save the result of calculations only if there are changes in the form. For instance, when a user clicks the "Calculate" button for the first time, ...

Is it possible for an Express app.get() function to identify and handle requests for specific file extensions

Is it possible for me to manage requests for any .html file type? For example, can I achieve something like this: // server.js app.get('/*.html', (req, res) => { // perform certain actions when an html file request is made }); ...

Can you explain the functionality of the container prop within the Drawer component of material-ui?

While delving into the official documentation for material-ui's Drawer component, I stumbled upon a mysterious container prop that is not explicitly mentioned in the API documentation. Could this possibly be one of the inherent props of a React compon ...

While trying to set up a development server in Firebase, I mistakenly deleted my build folder

I recently encountered an issue with my Firebase project. While trying to set up a development server for my existing React web app that is already in production, I ran into some unexpected problems. firebase use bizzy-book-dev firebase init firebase ...

Explaining the process of refreshing a JWT token in Django REST connected to an Angular frontend

Currently, I am utilizing this resource: I find myself puzzled on how to implement it properly. I have followed all the specified settings. So, how can I make it function correctly? At the moment, my code retrieves the initial token when a user submits t ...

How to dynamically add list items to a jQuery Mobile list using Ajax requests

Included in my index.html is a list view: <section id="dashboard" data-role="page" data-transition="slide"> <header data-role="header"> <h1>Trips</h1> <a href="#addTrip" id="createNewTrip" d ...

Toggle the display of input fields based on radio button selection in Angular 2

We want to dynamically display additional input fields based on the selected radio button. Radio <div class="form-group"> <label>What would you like to evaluate?</label> <div class="radio"> <label> ...

Bringing back a string from an external Ajax call

Learning something new can be challenging, so please bear with me: I've set out to create an image gallery that features a main index page where users can select various project categories, a sub-index page for selecting specific projects within the ...

Issue: Using the useParams() hook triggers a TypeError, stating that useContext(...) is undefined

Having trouble with the useParams() react hook to fetch a parameter, and encountering this error: Error: useContext(...) is undefined The hooks file throws this error on line 40: /modules/hooks.js:40 39 | > 40 | const match = useContext(Context) ...

Creating methods that are shared, privileged, and publicly accessible: A guide

Currently, some methods in one of my classes are public but can access private variables due to being privileged. This is because they are generated in the class constructor, allowing their closure to have access to the object closure. However, I am conce ...

The value of req.body becomes null following a post request

I've been working on creating a contact form with the help of nodemailer. When trying to submit it using the fetch API, I encountered an issue where req.body is being returned as undefined. Below is the frontend code snippet: form.onsubmit = functio ...

Crafting an interactive SVG element that maintains its clickability without interfering with mouseLeave events

Trying to Achieve: Changing color and displaying SVG when hovering over a row Clicking the SVG triggers a function, including external functions (not limited to ones defined inside script tags) Returning the row to its original form when mouse leaves Cha ...

Dynamic Dropdown Validation During Form Submission

In the form, there are multiple rows displayed dynamically, each with a dropdown menu. The id for each dropdown is "ReasonCd#" where "#" increments from 0 based on the row number. By default, every dropdown has "Select Number" as the selected option, with ...

Can links be integrated into Bootstrap 4 nav-pills tab-panel from another webpage?

I've managed to set up a service page with bootstrap 4's pills .nav-pills navigation, and it's functioning quite well. However, my current challenge involves allowing users to click on a link from the home page that will direct them to a spe ...

Efficiently centering content in a grid layout using automatic fit repetition for optimized responsiveness

I've implemented a responsive grid where each item has its own hidden details section that is revealed upon clicking the item. The structure of the HTML/CSS setup is as follows: <div class="grid"> <div class="item"> ...

Unable to successfully import an external HTML file that contains a script tag

I am currently experiencing an issue with my index.html <!doctype html> <html lang="en"> <head> <meta charset="utf-8> <title>MyApp</title> <link rel="import" href="./common.html"> </head> <body> ...

Using recursive functions in Javascript to modify or remove objects from an array by their unique identifier

I am attempting to develop two recursive functions to "iterate" over an array of objects as shown below. I believe the two functions are quite similar, but they serve different purposes. Function 1 is designed to update the object - it can modify every fi ...

Customizing the Image Insert Dialog in Pagedown Editor

I've developed a custom insertImageDialog hook to enable file uploads directly within the editor. $('div#insertImageDialog input[type=file]').ajaxfileupload({ action: $file.attr('data-action'), ...

What is the process for generating a comprehensive HTML table using AngularJS?

I have a set of data that needs to be dynamically loaded into an HTML page. Currently, I am using AngularJS to populate each table on the page. As of now, there are 8 tables in total. My goal is to make the table counts completely dynamic so that I can e ...