chieffancypants / angular-hotkeys

Configuration-centric keyboard shortcuts for your Angular apps.
http://chieffancypants.github.io/angular-hotkeys/
MIT License
1.68k stars 254 forks source link

In callback function array is not visible from scope #283

Open bestin-it opened 6 years ago

bestin-it commented 6 years ago

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' });
            }
aramando commented 6 years ago

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

bestin-it commented 6 years ago

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

aramando commented 6 years ago

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.