Home>
I am renovating an application made with AngularJs on the screen side.
I want to get the ID of the item selected in the select menu, but the html display shows the item's No and name.
Currently, the information that has been passed to the server side is No.
No is a value that the user can change, so if a duplicate occurs, an error will occur, so I want to get an ID to avoid this.
AngularJs version: 1.3.0
<select
ng-model = "item.exampleNo"
ng-options = "'' + c.exampleNo as (c.exampleNo + ':' + c.name) for c in item.exampleList"
ng-disabled = "false"
required>
</select>
Options contents
$scope.exampleList = [
{name: "A", exampleNo: "1", exampleId: "101"},
{name: "B", exampleNo: "2", exampleId: "102"},
{name: "C", exampleNo: "3", exampleId: "103"},
{name: "D", exampleNo: "4", exampleId: "104"},
{name: "E", exampleNo: "5", exampleId: "105"}
];
I thought that the contents of the array can be obtained because it contains an ID,
It could not be acquired as ng-model = "item.exampleId".
You can get the ID, but you can get the name and pass it to the server side.
* I tried to get the name with ng-model = "item.name" but could not get it.
Please teach me.
-
Answer # 1
Related articles
- javascript - i want to hide the information displayed in the select box when it is selected
- javascript - assign the same value selected in the select box to the api variable and reload the graph
- javascript - show only selected elements → select again to make the selected element at the bottom → show the remaining items at
- javascript - i want to add a line to the thumbnail selected in the slide show with thumbnails
- javascript - jquery i want to select a specific element
- javascript - i want to preview the content selected by v-select in vuejs
- javascript get the selected option value
- i don't know how to decorate the selected text with javascript (jquery)
- javascript - i want to display the select data that is rotating the display contents in a loop in the modal of bootstrap
- javascript - i want to hide the label together with the select box in html
- javascript - i want to be able to select the text while making the tag behave like a nest
- if you put a line break in the alert dialog of javascript, you can not select the character string
- javascript - although the option tag of html is rewritten to "selected" in ajax, the selected value is not displayed i
- javascript - how to select and delete with a check box
- javascript - you can't select elements with js id="sample[0]" ← like that
- javascript - acquisition of select value, calculation in which select value and input value are mixed
- javascript - i want to use two dropdown contents that use select tag to narrow down the selection and combine it with the chosen
- javascript - how to use multiple select box refinements using the chosenjs library
- 16 mass roulette with javascript (implementation of function not selected again)
- javascript - when saving data using ajax, the data selected by collection_select is displayed in the view with the id number
Related questions
- javascript : How to get the size of the browser window using js or python and transfer this size to the css file?
- javascript : HTML + CSS + JS. Working with canvas does not save image
- javascript : How to display part of an image on a website
- javascript : Two-column dropdown menu
- javascript : How do I make a regular div block work like input range?
- javascript : Encoding consisting of /letters and numbers
- javascript : Display the 1st column of the dropdown menu [duplicate]
- javascript : How to change the style file in index when clicking on the slider?
- javascript : Adjusting window.open () window height for different screens
- javascript : Draw a "round" line without breaks
Self-solved.
Id was successfully obtained by changing "c.exampleNo" in ng-options of html to "c.exampleId".
I'm sorry.