I created an Angular app. In my app I have a checkbox. By checking the checkbox I add or remove shapes.
<div class="checkboxAndLabel">
<input type="checkbox" id="{{shape.id}}" name="checkbox"
ng-model="stage.isSelected" ng-click="controller.addOrRemoveShape(shape)"/>
<label for="{{shape.id}}"></label>
</div>
The function:
myApp.controller('Controller', [ function(){
this.addOrRemoveShape = function(shape){
if (shape){
var isSelected = shape.isSelected;
if (isSelected === true){
//ADD SHAPE
}
else{
//REMOVE SHAPE
}
}
....
This function works perfect. If I put a breakpoint - when I will click on the checkbox I will go to this function.
In another place I added a button. When a user clicks on the button some shapes have to be added and of course the checkboxes have to be checked.
this.showOrHidePredefinedShapes = function (layer){
var shapes = layer.shapes;
for (var i .... shapes.length){
var shape = shapes[i];
shape.isSelected = true;
that.addOrRemoveShape(shape);
}
}
It is working. The shapes are drawn and the checkboxes are checked. However, when I click on the checkbox for the specific selected shapes in order to uncheck them the shape is removing but I can't enter into the breakpoint and the checkbox is still stayed checked. I don't understand why....
Aucun commentaire:
Enregistrer un commentaire