I have a form with 10 fields and the form looks like in the image i have mentioned here
As you can see in the image, one there are input fields and checkboxes. Here i want to tick the each check box after entering value to input with the mobile's enter key on the keyboard . I have tried with the directive from this stackoverflow ans.
I would like to add my code here , please suggest me if i am doing anything wrong in the code or logic.
Here is my html code :
<label class="item item-input">
<input type="text" next placeholder="In a word, what is important to you?" ng-model="values.first" ng-disabled="success.first">
<ion-checkbox ng-click="toggleCheckBox(success.first,values.first,0)" ng-change="show2='true'" ng-model="success.first"
ng-disabled="!values.first" style="border: none;padding-left: 30px;" class="checkbox-royal"></ion-checkbox>
</label>
<label class="item item-input" ng-show="show2" ng-class="{'animated-custom slideInLeft':success.first}">
<input type="text" next placeholder="What else is important to you?" ng-model="values.second" ng-disabled="success.second">
<ion-checkbox class="checkbox-royal" ng-model="success.second" ng-click="toggleCheckBox(success.second,values.second,1)" ng-change="show3='true'" ng-disabled="!values.second" style="border: none;padding-left: 30px;"></ion-checkbox>
</label>
And here is the controller snippet:
var values = [],obj={};
$scope.toggleCheckBox = function(isChecked, value) {
values = []; // Clean the values
obj[value] = (isChecked) ? true : false;
Object.keys(obj).forEach(function(k) {
obj[k] && values.push(k); // Fill the ordered values
});
};