简体   繁体   English

离子框架中的多个复选框

[英]Multiple checkbox in ionic framework

I am new in ionic framework.I am create one user profile and pass user input's through api url (yii2 api) . 我是ionic框架的新手。我创建一个用户个人资料,并通过api url(yii2 api)传递用户输入。 For example normal text field 例如普通文本字段

<input name="location" ng-model="data.location" type="text" placeholder="location" ng-required="true"> 

my api url like this 我的api网址是这样的

return $http.get('http://localhost/web/index.php?r=apiprofile/new&user_id='+$scope.data.user_id+'&location='+$scope.data.location)

This is working fine and the location value stored database correctly.But i use multiple checkbox means how to pass this url. 这工作正常并且位置值正确存储了数据库。但是我使用多个复选框表示如何传递此url。

<ion-checkbox  ng-model="data.jobtype1" ng-true-value="'parttime'">parttime</ion-checkbox>
<ion-checkbox  ng-model="data.jobtype2" ng-true-value="'fulltime'">fulltime</ion-checkbox>
<ion-checkbox  ng-model="data.jobtype3" ng-true-value="'contract'">contract</ion-checkbox>

I want user clicks three checkbox means look like this in database [parttime,fulltime,contract] that is same as in php multiple checkboxes. 我希望用户单击三个复选框,这意味着数据库[兼职,全职,合同]中的内容与php多个复选框中的内容相同。

I am already try same ng-model name for three checkbox ,but it is not working properly,when i click any one checkbox means all three checkbox is clicked and the database value is "undefined". 我已经尝试过为三个复选框使用相同的ng-model名称,但是当我单击任何一个复选框时,这意味着所有三个复选框均被单击,并且数据库值为“ undefined”,因此它无法正常工作。 And i passing like below url means the value in database like this [parttimefulltimecontract] 我像下面的URL那样传递意味着数据库中的值,例如[parttimefulltimecontract]

 return $http.get('http://localhost/web/index.php?r=apiprofile/new&user_id='+$scope.data.user_id+'&jobtype='+$scope.data.jobtype1+$scope.data.jobtype2+$scope.data.jobtype3)

Please help any one 请帮助任何一个

 <ion-checkbox ng-model="jobtype1" ng-true-value="parttime" ng-false-value="0" ng-checked="jobtype1== parttime" />

Try this. 尝试这个。

http://codepen.io/ionic/pen/hqcju http://codepen.io/ionic/pen/hqcju

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

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