Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular JS - Update input options with other input options

Tags:

angularjs

I have a form where I have to enter a country from a list in order to add different shipping costs to a total. As I am using ngCart directive, I have to use ng-click in order to send that info to the directive.

The problem is that I have two different input options with the same fields in different parts of the form, and I would like to update the value of one when I manually change the other, so that displayed option is always the same in both inputs.

I attach a http://jsfiddle.net/nf2z1a00/ with my code. Thanks in advance!

like image 930
Joe82 Avatar asked Sep 26 '26 07:09

Joe82


1 Answers

You can use ng-model on the select and use ng-options to take care of the options and the shipping like this:

<select ng-model="selectedCountry" ng-options="country.name for country in countries" ng-change="changeChipping()">
</select>

I've update your fiddle here

like image 51
Chantal Avatar answered Sep 28 '26 01:09

Chantal