We can select content of HTML element using element.select(). But onmouseup action the selected text by script will be deselected. So we have to disable onmouseup action.

Markup

<input ng-focus="selectAllContent($event)" ng-mouseup="$event.preventDefault();" value="sample value"/>

Script

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

2 comments:

  1. Awesome..took all of thirty minutes before coming to your post and solution. Thank you.

    ReplyDelete
  2. We’re A Leading & Trusted Directory Of The Best Online Brokers Review. Our Experience In The Industry Has Made Us Experts In Helping Traders Find The Most Suitable Brokerage Company For Them. Broker Forex Net Is An Online Portal Created For Traders To Help Them Find The Best Brokers And Strategies For Online Trading. Along With Broker Review And Login Details At Broker Forex We Offer Guest Post & Blog, Content Marketing Services, Link Building Services, And Much More. For More Details, Kindly Visit Our Website.

    ReplyDelete

Blogroll

Popular Posts