A
A
Aidar2016-08-02 11:13:50
Angular
Aidar, 2016-08-02 11:13:50

Why is select buggy in angular when choosing?

Hello! When selecting some items from the list, a completely different one is selected. Let's say we chose "Thickness 4-6" all the rules, "Thickness 8" all the rules, etc. , but when we select "Thickness 15-19" "Thickness 12" or another one is selected. As a result select works chaotically. I can't understand why this is happening.
Here is the link plnkr.co/edit/5F7nWMOHafIp9GNucqwD?p=preview , click select and see this glitch.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Tokarev, 2016-08-02
@Aderus

The problem is in the following place:

<select ... ng-options="value.price as value.name group by value.group for value in holes" ...>
...

You have value.price: as the selected parameter value.price as value.name, and this is a non-unique parameter. As a result, when choosing an item, the last element is selected, for which the specified price is equal to the selected value.
Solution: replace value.price as value.namewith value.id as value.name.
Why does what you call a glitch happen: when an element is selected, its price is taken and this value is assigned to the select and that's it. Those. in jQuery it would look like this:
$('select').val(190);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question