[Angular] HostListener Method Arguments - Blocking Default Keyboard Behavior
We are going to see how to using method arguments for @HostListener.
First, we can use HostListener without method arguments:
@HostListener('dblclick')
toggle(){
this.collapsed = !this.collapsed;
}
It works fine.
But if we need to get the $event object and do something with it, for example using preventDefault() from the event object. Then we need to use method arguments:
@HostListener('keydown', ['$event', '$event.keyCode'])
onKeyDown($event: KeyboardEvent, keyCode) {if(keyCode !== TAB) {
$event.preventDefault();
}
}
Here we inject '$event' and '$event.keyCode' into the method arguments. So for onKeyDown() method, we are able to inject those as well.
[Angular] HostListener Method Arguments - Blocking Default Keyboard Behavior的更多相关文章
- scala - multiple overloaded alternatives of method bar define default arguments
同名同位置默认参数不能overload def bar(i:Int,s:String="a"){} def bar(i:String,s:String="b") ...
- Default Keyboard Shortcut Schemes
Default Keyboard Shortcut Schemes All ReSharper actions can be invoked with keyboard shortcuts. Most ...
- 【PHP系列】PHP推荐标准之PSR-1,PSR-2
说起码代码,刚上大学那会,老师就教导我们,要严格,规范的,把代码写好.代码如人,工工整整.提起规范化的代码,从一开始用命令行编辑C语言代码就开始控制,强制自己按照相关的标准来,所以,现在写代码,不规范 ...
- H5活动全屏滚动页面在安卓智能电视TV调试
前段时间公司做一个线上活动,在电视上商品促销.产品的要求是每个商品介绍刚好满一屏,按下遥控器向下键可以整屏切换.这种功能如果实在PC端,实现起来非常容易,引用jQuery插件就能实现.但是在安卓智能电 ...
- Interface default method介绍
一.introduce interface default method Introduce default methodWrite the default method at interfaceTh ...
- Fedora 22中的Locale and Keyboard Configuration
Introduction The system locale specifies the language settings of system services and user interface ...
- angular源码分析:angular的整个加载流程
在前面,我们讲了angular的目录结构.JQLite以及依赖注入的实现,在这一期中我们将重点分析angular的整个框架的加载流程. 一.从源代码的编译顺序开始 下面是我们在目录结构哪一期理出的an ...
- Angular源代码学习笔记-原创
时间:2014年12月15日 14:15:10 /** * @license AngularJS v1.3.0-beta.15 * (c) 2010-2014 Google, Inc. http:// ...
- angular核心原理解析1:angular自启动过程
angularJS的源代码整体上来说是一个自执行函数,在angularJS加载完成后,就会自动执行了. angular源代码中: angular = window.angular || (window ...
随机推荐
- Raid阵列之简单介绍
1.raid分类 软raid:用软件模拟raid芯片 硬raid:集成的后来添加的 2.raid基本简介 (1)raid是由廉价磁盘冗余阵列发展成为独立磁盘冗余阵列 (2)linux是借助MD(Mui ...
- es6 -- set 数据结构
ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set 本身是一个构造函数,用来生成 Set 数据结构. const s = new Set(); [2, 3 ...
- pidof---查找指定名称的进程的进程号id号。
pidof命令用于查找指定名称的进程的进程号id号. 语法 pidof(选项)(参数) 选项 -s:仅返回一个进程号: -c:仅显示具有相同“root”目录的进程: -x:显示由脚本开启的进程: -o ...
- groupdel---删除指定的工作组
groupdel命令 groupdel命令用于删除指定的工作组,本命令要修改的系统文件包括/ect/group和/ect/gshadow.若该群组中仍包括某些用户,则必须先删除这些用户后,方能删除群组 ...
- 03007_JDBC概述
1.JDBC概述 (1)JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用J ...
- 洛谷 P1911 L国的战斗之排兵布阵
P1911 L国的战斗之排兵布阵 题目背景 L国即将与I国发动战争!! 题目描述 L国的指挥官想让他的每一个军营都呈现出国徽形——“L”形(方向无所谓).当然,他的指挥营除外(这叫做个性),他想不出该 ...
- ios UITextView 提示文本
定义两个UITextView,一个用于输入文本,一个用于显示提示信息,当输入文本为空时显示提示信息,否则不显示提示信息. //6.3.1文字内容提示 _contentTextViewTip = [[U ...
- linux下uboot kernel操作cpu寄存器
大多数的内核里面都有会对GPIO的操作,而且内核里面对GPIO进行配置也很方便,要什么功能就配置成什么就可以了. 还有一些寄存器是内核没有配置到的,但是我们要操作怎么办,内核里面也定义了相关的接口函数 ...
- BZOJ 1009 GT考试 (AC自动机 + 矩阵乘法加速dp)
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1009 题意: 准考证号为\(n\)位数\(X_1X_2....X_n(0<=X_ ...
- weblogic12
http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html 建立ejb http://docs.oracle. ...