@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. 75.《nodejs开发指南》express4.x版-微博案例完整实现

    转自:https://blog.csdn.net/cgwcgw_/article/details/39317587 完整代码下载 https://github.com/haishangfeie/wei ...

  2. solrj简介

    SolrJ基于httpClient: 使用SolrJ操作Solr会比利用httpClient来操作Solr要简单. SolrJ是封装了httpClient方法,来操作solr的API的. SolrJ底 ...

  3. 自己增删改查Razor页面

    AccountContext db = new AccountContext(); public ActionResult Index() { return View(db.SysUsers); } ...

  4. spark network-common

    概述 Spark底层使用netty作为节点间通信的桥梁.其实现在common/network-common包中.common/network-common包主要是对netty进行了一层封装,主要是定义 ...

  5. sync---强制将被改变的内容立刻写入磁盘

    sync命令用于强制被改变的内容立刻写入磁盘,更新超块信息. 在Linux/Unix系统中,在文件或数据处理过程中一般先放到内存缓冲区中,等到适当的时候再写入磁盘,以提高系统的运行效率.sync命令则 ...

  6. FZU 1921 栀子花开

    栀子花开 Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 19216 ...

  7. Linux(centos)下mysql编译安装教程

    Linux下mysql编译安装教程 #查看linux发行版本 cat /etc/issue #查看linux内核版本号 uname -r 本文測试环境centOS6.6 一.Linux下编译安装MyS ...

  8. 关于使用strtok的一个小问题

    今天在弄一下啊小小程序的时候.报错,出现了问题.先看代码 int main(int argc, char* argv[]) { char *filename = "interface_ips ...

  9. shell-手机屏幕录制

    今天在做android联系的时候,想要把自己写的demo效果记录下来.在网上发现了录制手机屏幕的方法,如下 adb shell screenrecord /sdcard/demo.mp4 解释 adb ...

  10. 31.Node.js 常用工具 util

    转自:http://www.runoob.com/nodejs/nodejs-module-system.html util 是一个Node.js 核心模块,提供常用函数的集合,用于弥补核心JavaS ...