T
T
Test Test2015-01-24 22:03:17
JavaScript
Test Test, 2015-01-24 22:03:17

How does Angular.JS work with select?

Good evening. I was wondering how Angular.JS works with select. For example, I have an
HTML list like this (fragment):

...
<select ng-model="form.currency" ng-options="c as c.label for c in currencies"></select>

{form | json}
...

Javascript (fragment inside controller):
$scope.currencies = [
        {label : 'Доллары', value : 'usd'} ,
        {label : 'Евро' , value : 'eur'}
    ];

Everything works fine if I change the data from the browser. But if I need to change the selected element using Javascript while working with the list, then the model does not change.
select.find('option').eq(1).prop('selected' , true);

Do not tell me how to intercept this moment so that the model changes properly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dedukhin, 2015-01-24
@cubooks

Now there is no way to check, but perhaps after such a change it is necessary to do
angular.element(select).scope().$apply();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question