Angular JS-使用其他输入选项更新输入选项 [英] Angular JS - Update input options with other input options
问题描述
我有一个表格,必须在清单中输入一个国家/地区,以便将总计的运输费用加在一起.当我使用ngCart指令时,必须使用 ng-click
将该信息发送到该指令.
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.
问题是我有两个不同的 input选项
,它们在表单的不同部分具有相同的字段,并且当我手动更改另一个时,我想更新其中一个的值,以便两个输入中显示的选项始终相同.
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.
我在代码中附加了 http://jsfiddle.net/nf2z1a00/.预先感谢!
I attach a http://jsfiddle.net/nf2z1a00/ with my code. Thanks in advance!
推荐答案
您可以在select上使用ng-model,并使用ng-options来照顾选项和交付,如下所示:
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>
我已经在此处
这篇关于Angular JS-使用其他输入选项更新输入选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!