【问题标题】:Perform a function when radio button is clicked angularjs [duplicate]单击单选按钮时执行功能angularjs [重复]
【发布时间】:2014-08-01 18:06:26
【问题描述】:

我有 2 个性别单选按钮,分别是男性和女性。当我单击男性按钮时,应在控制器中执行一些操作。与女性按钮相同。但在我的代码中,只有男性按钮点击有效。我的代码有什么问题

筛选依据:

        <label>

            <input type="radio" name="optionsRadios" id="optionsRadios1" 
            ng-model="Tofilter.sex" value="male" ng-click="checkStuff()" checked>
            <label for="gender" class="control-label col-xs-2">Male</label>
        </label>
        <label>
            <input type="radio" name="optionsRadios" id="optionsRadios2" 
            ng-model="Tofilter.sex" value="female" ng-click="checkStuff()">
            <label for="gender" class="control-label col-xs-2">Female</label>
        </label>
    </div>

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    尝试使用ngChange 代替ngClick(参见Angular input[radio] Doc)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      相关资源
      最近更新 更多