代码之家  ›  专栏  ›  技术社区  ›  Vanu

在IE11中点击angular2,在输入文本字段中选择文本

  •  1
  • Vanu  · 技术社区  · 7 年前

    我用Angular2编写了以下代码,它在Google Chrome中运行良好,但在IE11中不起作用。

    <input type="text" name="Description" id="Description" [(ngModel)]="Description" maxlength="20" (click)="$event.target.select()">
    

    我四处寻找,想找到一条有棱角的路。在Angularjs中,可以使用指令来实现这一点。我可以在Angular2中实现同样的功能吗?它同样适用于Firefox、Chrome和IE。

    1 回复  |  直到 7 年前
        1
  •  2
  •   Salander    7 年前

    如本文所示,您可以使用angular2提供的(焦点)事件 plunker

    <input type="text" name="Description" placeholder={{description}} [(ngModel)]="description" maxlength="20" (focus)="$event.target.select()">
      <div *ngIf="selectedValue">{{selectedValue}}</div>