Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

Checkboxes somehow auto uncheck in emulator

$
0
0

@nikits wrote:

I came up with very interesting problem. I'm developing an application with ionic framework in which I have an array of objects representing my states of the checkboxes and their values. I would like to set up a notification every time a checkbox has been checked and I would like to cancel the given notification when the given checkbox is unchecked. The problem is that every time I check a given checkbox and I try to click something else after that - the current checkbox triggers its ng-click function again without me clicking on it. I tested this in the browser and it works correctly. But it doesn't work with the iOS emulator.

Any thoughts why this is happening?

Note: The code for the notifications is not added during the debugging. Because it won't work in the browser.

I have the following code in my view.

<span ng-repeat="item in alerts">
<label class="checkbox" for="{{ item.text }}">
<input type="checkbox" ng-model="item.checked" ng-click="alertSubmit(item)" />
{{ item.text }}
</label>
</span>

And this is what I have in my controller.

`$scope.alerts = [
{ id: 0, text: "5 seconds", checked: false},
{ id: 1, text: "10 seconds", checked: true},
{ id: 2, text: "15 seconds", checked: false},
{ id: 3, text: "20 seconds", checked: false}
];

$scope.alertSubmit = function(newAlert){
if(newAlert.checked == true){
alert("true");
$scope.alerts[newAlert.id].checked = true;
alert("will schedule a notification");
// code which shedules notification shuld go here
}
else{
alert("false");
$scope.alerts[newAlert.id].checked = false;
alert("will cancel the notification");
// code which cancel notification shuld go here
}
}`

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>