我需要通过 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/