【问题标题】:How to add many functions in ONE ng-change?如何在 ONE ng-change 中添加许多功能?
【发布时间】:2016-04-11 22:58:26
【问题描述】:

如何在ng-change中添加多个函数?

示例代码:

<div class="col-md-2">
    <select id="sel2" ng-model="updateUser.user.state" name="state"
        ng-change="change(); updateUser.user.city=''"
        data-role="listview" required>
    <option value="">Select State</option>
    </select>
</div>

【问题讨论】:

  • 为什么不使用一个函数来调用所有其他函数?
  • 但我正在尝试以相同形式更改州下拉菜单后重置城市下拉菜单...
  • @MarcCliment 我尝试过类似 ng-click 格式...但无法正常工作

标签: html angularjs


【解决方案1】:

您只需执行以下操作

<div class="col-md-2">
<select id="sel2" ng-model="updateUser.user.state" name="state"
    ng-change="change1(); change2(); updateUser.user.city=''"
    data-role="listview" required>
<option value="">Select State</option>
</select>

【讨论】:

    【解决方案2】:

    您需要创建一个委托函数。浏览这篇文章,它应该可以帮助您入门。

    ng-change on select option calling multiple unique functions

    【讨论】:

      猜你喜欢
      • 2013-05-24
      • 2021-04-17
      • 1970-01-01
      • 2017-11-19
      • 2019-01-02
      • 2020-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多