Automatically Angularjs Set focus input from controller

Automatically Angularjs Set focus input from controller

In this Post We Will Explain About is Automatically Angularjs Set focus input from controller With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Angular js auto focus for input box Example

In this post we will show you Best way to implement Focus on input field in AngularJS, hear for angularjs – How to set focus on input field with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Setting Focus on input field with AngularJS

In this Example,First of all Add or Inluce External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priorty set.After that Include your relavant CSS Class.

Simple Create a angular directive for HTML Input box autofocus and simple use where ever We need on the angular module.

Angular Directive(index.html)

// Common directive for Focus

angular.module('liveApp').directive('focus',
function($timeout) {
 return {
 scope : {
   trigger : '@focus'
 },
 link : function(scope, element) {
  scope.$watch('trigger', function(value) {
    if (value === "true") {
      $timeout(function() {
       element[0].focus();
      });
   }
 });
 }
};
}); 

index.js(View)

<div>
    <div>
        
<div class="liveFocus">
    <h1>Pakainfo.com - >Auto Focus : </h1>
        With Out Focus : <br><br>
    Live Auto Focus : <br><br>
 </div>       
    </div>
</div>

style.css

.liveFocus{
    margin:10px 10px;
}
h1{
    margin-bottom:10px;
    font-size:18px;
}

You are Most welcome in my youtube Channel Please shubscibe my channel. and give me feedBackMore Details……
Angularjs Example

Example

I hope you have Got What is AngularJS: auto focus into input field And how it works.I would Like to have FeaeBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Lenovo laptop wifi Solution steps - Fix lenovo z570 z580 WiFi Issues
  2.   Angular 6 Components Tutorial with Examples
  3.   Dynamically Change Form Action Based on Select Option
  4.   Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects
  5.   Bash if else statement using Bash Scripting
  6.   Vuejs autocomplete search with typeahead js
  7.   ViewData VS ViewBag Vs TempData using ASP.Net MVC
  8.   User Profile Edit Script Update Script Laravel 7/6
  9.   How to uninstall cordova and ionic in ubuntu
  10.   Laravel Validation and Bootstrap Modal Popup Form Submit with Ajax