在找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 1 Failed to read the 'selectionStart' property from 'HTMLInputElement':的更多相关文章

  1. angularjs 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. Annotation详解

    转自:http://www.doc88.com/p-995532241886.html 首先我们定义一个简单的注解 package com.qjy.annotation; import java.la ...

  2. 牛客多校第十场 F Popping Balloons 线段树维护稀疏矩阵

    题意: 给定一个稀疏矩阵,里面有若干个气球,让你横着开三枪,竖着开三枪,问最多能打爆多少气球,要求相同方向,相邻两枪必须间隔r. 题解: 横向记录每列有多少个气球,分别在哪行上. 然后把这个数据改造成 ...

  3. C语言进阶学习第三章

    以下记录动态内存分配: 1.malloc和free malloc和free分别用于执行动态内存分配和释放.这些函数维护一个可用内存池,当一个程序需要一些内存时,调用malloc函数,malloc从内存 ...

  4. WebStorm+Node.js开发环境的配置

    1 下载地址:  webstorm:http://www.jetbrains.com/webstorm node.js:https://nodejs.org/download/ 2 安装node.js ...

  5. 使用QSlider

    1.当绘制的线性图等需要水平拖动的时候(不用qwt里面的函数),可以用QSlider,代码如下 ui.horizontalSlider->setMaximum(); //需要拖动的越缓慢,平滑它 ...

  6. Python匹马行天下之_循环

    一.while循环 如果条件成立(true),重复执行相同操作,条件不符合,跳出循环 while   循环条件: 循环操作 (1)while循环示例 例:输入王晓明5门课程的考试成绩,计算平均成绩 1 ...

  7. R:ggplot2数据可视化——进阶(3)

    Part 3: Top 50 ggplot2 Visualizations - The Master List, 结合进阶1.2内容构建图形 有效的图形是: 不扭曲事实 传递正确的信息 简洁优雅 美观 ...

  8. 5-Python操作MySQL步骤

    1.引入模块 在py文件中引入pymysql模块 from pymysql import *(connect) 2.创建connection连接对象 conn=connect(参数列表) 参数host ...

  9. USACO 2008 January Silver Telephone Lines /// 二分最短路 邻接表dijkstra oj22924

    题目大意: 一共有N (1 ≤ N ≤ 1,000)个电线杆,有P P (1 ≤ P ≤ 10,000)对电线杆是可以连接的, 用几条线连接在一起的电线杆之间都可相互通信,现在想要使得电线杆1和电线杆 ...

  10. Flutter 打包报错 : Unknown FLUTTER_BUILD_MODE: xxx

    概要 在集成flutter 工程之后,我们的工程在debug 和release 模式下都没什么问题,一切都很顺利.但是我们在打企业包的时候却出现了错误: Showing Recent Errors O ...