gpt4 book ai didi

javascript - AngularJS 输入字段复选框 ng-click 不触发方法

转载 作者:行者123 更新时间:2023-11-30 11:15:59 25 4
gpt4 key购买 nike

我需要通过 ng-click 调用切换开关中的函数,但是 customerActiveDeactive 函数没有触发。

<a title="Active/ Deactivate" >
<input type="checkbox" class="js-switch" ng-init="status=True" ng-model="status" ng-name="status" ng-checked="{{ customer.status|lower }}" ng-click="customerActiveDeactive({{ customer.id }})" />
</a>

$scope.customerActiveDeactive = function(id) {
console.log("method call");
}

最佳答案

您以错误的方式将变量作为参数传递:这样做:

<a title="Active/ Deactivate" >
<input type="checkbox" class="js-switch" ng-init="status=True" ng-model="status" ng-name="status" ng-checked="{{ customer.status|lower }}" ng-click="customerActiveDeactive(customer.id )" />
</a>

$scope.customerActiveDeactive = function(id) {
console.log("method call");
}

关于javascript - AngularJS 输入字段复选框 ng-click 不触发方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51518380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com