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

bindTo equivalent for component controller? #243

Open samjulien opened 7 years ago

samjulien commented 7 years ago

Hi folks,

I recently upgraded my app to Angular 1.5.8 and am gradually converting my controllers and directives to components. In my directives I was doing:

hotkeys.bindTo(scope)
           .add(
               {
                   combo: 'p f',
                   description: 'Create a forecast for a project',
                   callback: function () {
                       vm.openGroup = true;
                       vm.edit();
                   }
               }
            )

This no longer works with a component's controller. For now I'm just going to use the $onDestroy lifecycle hook to remove the hotkeys, but this will get tedious, especially on pages with lots and lots of hotkeys. Thoughts?

P.S. It also looks like chaining adds no longer works, unless I'm missing something.

Thanks so much, this is a great directive!

ingow commented 7 years ago

I am in the same boat. I will try to use the route hotkeys, if that doesnt work I must look for another package I guess.

tcrite commented 7 years ago

@samjulien can you tell me why this doesn't work?