输入禁用指令选择所有角度

时间:2014-07-29 16:37:43

标签: angularjs input directive

我希望输入文本被禁用,但是当你点击它时也会选择全部。

这是一个有效的工作人员

http://plnkr.co/edit/o2hu8MCU2bjVPPFhhBLx?p=info

这是我的指示:

app.directive('selectAll', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            element.on('click', function () {
                this.select();
            });
        }
    };
})

和html:

  <input type="text" disabled select-All size="60" value="http://google.com"> - directive with disabled
  <br>
  <input type="text" select-All size="60" value="http://google.com"> - directive without disabled

我希望输入不可编辑,但仍然允许select all指令工作。

我尝试将禁用的功能添加到指令中,但我有时也将此指令用于输入以外的其他内容。

任何指导?

1 个答案:

答案 0 :(得分:1)

所以,garuuk,使用readonly而不是disabled,只是将输入设置为看起来已禁用。也许略微不透明

相关问题