angular-hotkeys icon indicating copy to clipboard operation
angular-hotkeys copied to clipboard

In callback function array is not visible from scope

Open bestin-it opened this issue 6 years ago • 3 comments

Hi,

when you run $scope.AddItem function for example 3 times and call function $scope.Test you will see that the size of $scope.items is equal 3. But when you click 'del' you will see that $scope.items size is 0.

Why ?

        hotkeys.bindTo($scope)
            .add({
                combo: 'del',
                description: 'blah blah',
                callback: function () {
                    $scope.Test();
                }
            })

           
            $scope.Test = function()
            {
                alert($scope.items.length);
            }

            $scope.AddItem = function()
            {
                $scope.items.push({ test: 'Test' });
            }

bestin-it avatar May 04 '18 10:05 bestin-it

Works fine for me: https://plnkr.co/MtiI5X

aramando avatar May 08 '18 10:05 aramando

The link does not work. Can you send working example ?

bestin-it avatar May 14 '18 02:05 bestin-it

Hmm yeah it seems to have trouble loading, but if you click the "Launch in Editor" button you can see the code and run it.

aramando avatar May 15 '18 11:05 aramando