host属性
@Component({
selector: ‘jhi-project‘,
templateUrl: ‘./project.html‘,
styleUrls: [],
host: { ‘(window:keydown)‘: ‘keyboardInput($event)‘ }
//绑定事件和方法
})
export class JhiProjectComponent {
keyboardInput(event) {
if (event.keyCode == 65 && event.ctrlKey) {
// ctrl + a
....
}
}
}