在找angularjs input(type='number')在获取焦点的时候,文本框内容选中效果,参考了:Select text on input focus,我直接复制他的code之后,在ionic中报"Uncaught InvalidStateError: Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not support selection.",

尝试了

---

this.setSelectionRange(0, 9999)

---

this.selectionStart = 0;
this.selectionEnd = 999;

上面两个选中文本,我在webapp中测试的时候,需要每次双击之后才会有效果,我尝试用jQuery的select()方法来达到这个效果,再ionic编译的apk中测试可用之后,觉得这是我目前的解决方法。

directive方法代码

.directive('selectOnClick',  function ($window) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', function () {
if (!$window.getSelection().toString()) {
// Required for mobile Safari
$(this).select();
}
});
}
};
})

input使用这个directive(指令)像:

<input type="text" value="test" select-on-click />

再android app中,使用type="number"也可以工作。

angularjs Failed to read the 'selectionStart' property from 'HTMLInputElement':的更多相关文章

  1. angularjs 1 Failed to read the 'selectionStart' property from 'HTMLInputElement':

    在找angularjs input(type='number')在获取焦点的时候,文本框内容选中效果,参考了:Select text on input focus,我直接复制他的code之后,在ion ...

  2. select2取值报错,Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('hidden') does not support selection.

    用到了 select2 组件来多选收件人,用搜狗浏览器(6.2版高速模式)在执行到如下这句时报错(Uncaught InvalidStateError: Failed to read the 'sel ...

  3. Uncaught InvalidStateError: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.

    使用 HTML5 的图片上传api的时候报如下错误: Uncaught InvalidStateError: Failed to set the 'value' property on 'HTMLIn ...

  4. Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.

    今天上传图片遇到这个报错 百度了下,网上说是input标签type=file所以导致的问题,可是我的type=hidden 解决办法: 把上面的代码改成如下问题就解决了

  5. react中报错Failed to set an indexed property on 'CSSStyleDeclaration': Index property setter is not supported

    产生这个报错的原因是我当时将样式写到了less文件,我在div中使用的使用应该是使用className = ,而我误写了一个style = .style里面当然没有自定义的className,所以产生 ...

  6. jq ajax遇到的错误集合

    一.错误: Uncaught InvalidStateError: Failed to read the 'selectionDirection' property from 'HTMLInputEl ...

  7. jquery 常见问题--转载

    1 JQuery操作radio     1)获取按钮选中的值:$("input:radio:checked").val();     2)选中或者取消选中某个Radio的方法,可以 ...

  8. js清空input file的值

    原文:js清空input file的值 在做选择本地图片上传的功能时遇到一个问题,第一次点file按钮选择图片完成会触发onchange事件,获取文件后动态在界面上创建img标签展示,但把创建的img ...

  9. appium windows 命令行中运行以及targetSdkVersionFromManifest failed的解决

    启动appium服务,可以通过appium.exe可执行文件启动,也可以通过命令行启动.appium.exe启动需要通过安装可执行文件,命令行启动需要通过npm安装appium.可执行文件启动方式如下 ...

随机推荐

  1. 【DOM】2.闭包

    1.什么是闭包? 函数嵌套函数 内部函数可以引用外部函数的参数和变量 参数和变量不会被JS中的垃圾回收机制 所收回 2.闭包有啥好处?应用在哪? ①希望一个变量长期驻扎在内存中 ②避免全局变量的污染 ...

  2. uvalive 3218 Find the Border

    题意:一条封闭折线将平面分成了若干个区域,按顺序给出折线各点的坐标,要求输出封闭折线的轮廓. 题解:用类似卷包裹的算法,先确定一个一定会被选中的点(x坐标最小,y坐标最小)作为起点,然后把可能是下一个 ...

  3. 设计原则 Design Principle

    Design Principle设计原则 最近由于碰到要参与设计一个音频处理系统,有人提议用一个大的全局变量结构体来做状态信息交流的地方,引起了我对设计一个系统的思考,于是找到了如下资料,当然,关于这 ...

  4. CentOS安装nvidia显卡驱动

    1.下载 nvidia 相应的驱动: 2.修改/etc/modprobe.d/blacklist.conf文件,在里面加入blacklist nouveau. 3.重建image $ mv /boot ...

  5. HW6.9

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. leetcode@ [62/63] Unique Paths II

    class Solution { public: int uniquePathsWithObstacles(vector<vector<int>>& obstacleG ...

  7. CF390-E. Inna and Large Sweet Matrix(区间更新+区间查询)

    题意很好理解,不说了 题解就是每次把值压缩成一维,比如x上,这样就可以求出任意宽度的整个竖条的和. 如这张图,求的是s5-(s1+s3+s7+s9) 因为可以求出一整竖条和一整横条,我们可以求出是s2 ...

  8. rank() | dense_rank() | row_number() over(PARTITION BY sex order by age desc ) 的区别

    1.row_num() over()函数:根据某个字段排序后编号1,2,3.. select *,ROW_NUMBER() over ( order by majorid) as numfrom St ...

  9. linux系统基础(二)

    磁盘管理(一) Linux设备认识 /dev/cdrom /dev/sr0 /dev/mouse /dev/sda /dev/hda IDE硬盘(支持4块):hd(a-d) [非IDE硬盘]SCSI硬 ...

  10. Zookeeper全解析——Paxos作为灵魂

    原文地址: http://www.spnguru.com/2010/08/zookeeper%E5%85%A8%E8%A7%A3%E6%9E%90%E2%80%94%E2%80%94paxos%E7% ...