I am using the angular-sortablejs plugin for sorting of the list in my application. Here I have two lists, list A and list B. When I am trying to drop an item from List A to List B, I am triggering onAddOriginal
event in list B.
where, in this event, I am changing a variable sortableWidget
value to true. This variable value is getting scoped inside onAddOriginal
event and I am not able to get the change value of the variable.
Here's my code:
selectedWidget: boolean = false ;
optionsForDroppableArea: SortablejsOptions = {
group: {
name: 'widgets',
put: true,
pull: true
},
onAddOriginal: function (evt) {
this.selectedWidget = true;
}
};
And when I am consoling the variable, I am getting the value as false
and not as true
.
deleteRow(){
console.log(this.selectedWidget);
}
Is there any way I could declare a boolean variable as false
. Then change the value to true
and able to access this variable all over the code as true. In other words, can I make this variable globally scoped?