简体   繁体   English

选中ion-checkbox时调用Ionic Ajax

[英]Ionic Ajax Call when ion-checkbox is checked

I am trying to make a database update if a checkbox is checked. 如果选中复选框,我正在尝试进行数据库更新。 Is there a way to do it with Ionic? 有没有办法用Ionic做到这一点? I don't want to refresh the view or go to a different view. 我不想刷新视图或转到其他视图。 Looking to do similar to the facebook like on the web. 希望做类似网络上的facebook。

ion-checkbox ng-model="myvalue" ion-checkbox ng-model =“ myvalue”

Yes. 是。 Basically you could to one of two thigs. 基本上,您可以选择两个雷鬼之一。

1) Create a ng-click on the checkbox that then calls a method on the controller which then calls a $http.put or whatever you like. 1)创建一个ng-单击复选框,然后在控制器上调用一个方法,然后再调用$ http.put或您喜欢的任何方法。 you could pass the value to the method or just read it from the model. 您可以将值传递给方法,也可以从模型中读取。

2) By putting a watch on myValue like this: 2)将手表放在myValue上,如下所示:

 $scope.$watch('myValue', function() {
        alert('myValue has changed!');
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM