How to select field contents when receiving focus?

1

I have a problem that seems to be simple, but it has taken me a long time looking for possible solutions and so far I have not been able to solve it.

I need to select the contents of an Input in an HTML form with Bootstrap when receiving focus.  

By default HTML5 already selects the contents of the field when receiving focus, however I'm using an angularJS (ng-currency) directive to format decimal places, and after adding the directive, does not select any more.

In short ...

  

What do I want?   

Well a picture is worth more than a thousand words, when receiving focus (tab for example) I want the content of the input to be all selected on screen:

  

WhathaveItriedtodo?

Iwasabletodointheclickeventinsidethefield,likethis:

<inputtype="text"
   class="col-sm-12 form-control"
   ng-model="campo"
   ng-currency currency-symbol=""
   ng-click="selectAllClick($event)">

$scope.selectAllClick = function ($event) {
   $event.target.select();
}

But I need to focus on the focus event, I've already tried to use ng-focus to call this function, but it does not work.

The directive I am using is this:   link

The problem that occurs is this:

Does anyone have any ideas?

    
asked by anonymous 19.04.2016 / 15:34

0 answers