3

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!

Joe82
  • 1,357
  • 2
  • 24
  • 40

2 Answers2

1

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

Chantal
  • 959
  • 2
  • 12
  • 24
0

Put same ng-model in you similar select boxes :

<select ng-model="shippingCountry">
   //first
</select>

<select ng-model="shippingCountry">
   //second : notice the same ng-model
</select>
Rambler
  • 4,994
  • 2
  • 20
  • 27
  • This solution works just partially, as it doesn't take care of the behaviour that I previously included in the ng-click. Thanks for the insight though! – Joe82 May 31 '16 at 12:41