Git Product home page Git Product logo

Comments (7)

mhussain001 avatar mhussain001 commented on July 20, 2024

@thekalinga Please find the example code here
(https://github.com/mhussain001/angular2-webpack-starter)

from angular2-hotkeys.

thekalinga avatar thekalinga commented on July 20, 2024

@mhussain001 Can u point me to a class within the other project where you have implemented this.

Also, it has to be documented in this project

from angular2-hotkeys.

mhussain001 avatar mhussain001 commented on July 20, 2024

@thekalinga Please refer https://github.com/mhussain001/angular2-webpack-starter/blob/master/src/app/app.component.ts

from angular2-hotkeys.

thekalinga avatar thekalinga commented on July 20, 2024

This is the way you register a global hotkey. But, the question talks about binding a hotkey such that the hotkey's life cycle is bound to the lifecycle of the component, not the whole app.

from angular2-hotkeys.

thekalinga avatar thekalinga commented on July 20, 2024

One way to do this is to add(register) and remove(unregister) in each of the component manually in OnInit & OnDestroy where I need component scoped hotkeys, so that the shortcuts are scoped only to the component.

I believe it should be done in a better way where the hotkey framework itself does the removal of this shortcut under the hood by removing the shortcut as soon as the onDestory is called on the component using the service.

I have just added a question in stackoverflow to see if Angular allows us to do this

from angular2-hotkeys.

k11k2 avatar k11k2 commented on July 20, 2024

@thekalinga did you achieve it ? i really need this one.

from angular2-hotkeys.

brtnshrdr avatar brtnshrdr commented on July 20, 2024

Yes, OnInit & OnDestroy is the recommended way for creating component scoped hotkeys

from angular2-hotkeys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.