@HostListener('keydown', ['$event', '$event.keyCode'])
onKeyDown($event: KeyboardEvent, keyCode) { if(keyCode !== TAB) {
$event.preventDefault();
} // get value for the key
const val = String.fromCharCode(keyCode);
// get position
const cursorPos = this.input.selectionStart; overWriteCharAtPosition(this.input, val, cursorPos);
} export const overWriteCharAtPosition = (
input: HTMLInputElement,
val: any,
position: number
) => {
const currentValue = input.value;
input.value = currentValue.slice(, position) + val + currentValue.slice(position+);
};

[Angular HTML] Overwrite input value, String.fromCharCode & input.selectionStart的更多相关文章

  1. Android input输入框 移动页面input手机键盘中的“搜索”按键

    动页面input手机键盘中的“搜索”按键 满足以下几点机即可: input type="search"    放到form标签中    使用action属性 <form ac ...

  2. 封装input 逐渐,且input插件必须带有默认值。

    封装input 逐渐,且input插件必须带有默认值. 组件: <template> <div class="input-show"> <span c ...

  3. 数组乘积--满足result[i] = input数组中除了input[i]之外所有数的乘积(假设不会溢出

    数组乘积(15分) 输入:一个长度为n的整数数组input 输出:一个长度为n的整数数组result,满足result[i] = input数组中除了input[i]之外所有数的乘积(假设不会溢出). ...

  4. Oracle delete input与delete all input

    oracle官方文档提示:If you had specified DELETE INPUT rather than DELETE ALL INPUT, then RMAN would have on ...

  5. input type类型和input表单属性

    一.input type类型 1.Input 类型 - email 在提交表单时,会自动验证 email 域的值. E-mail: <input type="email" n ...

  6. 定制 input[type="radio"] 和 input[type="checkbox"] 样式

    表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或 ...

  7. 修改 input[type="radio"] 和 input[type="checkbox"] 的默认样式

    表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或 ...

  8. angular自定义指令解决IE89不支持input的placeholder属性

    下面代码实测通过,直接copy到本地运行即可. <!DOCTYPE html> <html> <head> <meta charset="UTF-8 ...

  9. How to Construct the Input Bet String

    The purpose of this section is to describe the format of the string which will submitted to the Pyth ...

随机推荐

  1. ErrorSet

    1.获取路径的失误: 例子是对一个列表项的悬浮操作: ~(function() { var lists = $(".footer_log>li"); lists.each(f ...

  2. enable&&builtin---shell内部命令

    用enable命令显示所有激活的内部命令: [root@localhost ~]# enable -a builtin命令用于执行指定的shell内部命令,并返回内部命令的返回值 [root@xiao ...

  3. reboot---重启Linux系统

    reboot命令用来重新启动正在运行的Linux操作系统. 语法 reboot(选项) 选项 -d:重新开机时不把数据写入记录文件/var/tmp/wtmp.本参数具有“-n”参数效果: -f:强制重 ...

  4. 今日SGU 5.12

    SGU 149 题意:求每一个点的距离最远距离的点的长度 收获:次大值和最大值,dfs #include<bits/stdc++.h> #define de(x) cout<< ...

  5. 【2017 Multi-University Training Contest - Team 5】Rikka with Subset

    [Link]: [Description] 给你a数组的n个数的所有2^n个子集的2^n个子集元素的和; 子集元素的和最大为m; 告诉你各个子集元素的和出现的次数; 如 1 2 则0出现1次,1出现1 ...

  6. hive学习笔记-高级查询

    聚合函数 count计数 count(*):不全都是NULL.就加1:count(1):当仅仅要有一列是NULL就不会加1:count(col):当col列不为空就会加1 sum求和 sum(可转成数 ...

  7. 基于TC技术的网络流量控制实战

    本文转载在:http://server.it168.com/a2010/0426/878/000000878406.shtml 基于TC技术的网络流量控制实战 650) this.width=650; ...

  8. 界面实例--旋转的3d立方体

    好吧,这里直接编辑源码并不允许设置css和js……毕竟会有危险……那直接放代码吧 <!DOCTYPE html> <html> <head> <meta ch ...

  9. Mybatis批量插入,是否能够返回id列表

    第1次代码 void batchAdd(List<Photo> list); <insert id="batchAdd" parameterType=" ...

  10. nagios 安装配置(包含nrpe端)全 (一)

    一.nagios安装: 1.安装下面命令: 这是本人监控服务时自己定义插件所用到的几个系统命令.可不安装. (1)iostat:监控磁盘IO信息: apt-getinstall sysstat (2) ...