Angularjs set focus on first textbox

Ajax AngularJS Technology

Angularjs set focus on first textbox

In this Post We Will Explain About is Angularjs set focus on first textbox 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 How to set focus on first textbox of the page in angular, hear for Automatically Set Focus on a Textbox (Input Box) in AngularJS with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

External Include file

AngularJS is a simple JavaScript framework Include one type of the (library) based on a very user friedly popular software mvc based architecture menas called the MVC.

   <head>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
</head>

index.html

The Angular simple directives and the User’s view HTML DOM in a web-application page form the HTML view. In our example(Pakainfo.com), the simple HTML view comprises the HTML All the element, and then simple two angular directives Like as a namely angular ng-app as well as agular ng-controller

<body>
<h1>Angularjs set focus on first textbox Example</h1>
    <div ng-app="liveApp" ng-controller="liveCtrl">
<!-- Devloped by https://www.pakainfo.com free download examples -->
        <p>
            <input type="text" id="date" datepicker ng-model="val_date" 
                placeholder="Select a any date" />
        </p>
        <p ng-if="val_date" ng-init="simpleSetFocus()">
            <input type="text" placeholder="Please Enter some value" id="t" />
        </p>
    </div>
</body>

index.js

The simple angular controller works as a all the data of the mediator between HTML views and models.

<script>
    var liveApp = angular.module('liveApp', []);
    liveApp.controller('liveCtrl',
        function ($scope, $window) {

            $scope.simpleSetFocus = function () {
                var dataparam = $window.document.getElementById('t');
                dataparam.focus();
            };
        });
	//simple directive in angular
    liveApp.directive("datepicker", function () {
        function link(scope, element, attrs, controller) {
		//scope datepicker
            element.datepicker({
                onSelect: function (dt) {
				//apply datepicker function
                    scope.$apply(function () {
                        controller.$setViewValue(dt);
                    });
                },
                dateFormat: "mm/dd/yy"
            });
        }
        return { require: 'ngModel', link: link };
    });
</script>
</html>

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Automatically Set Focus on a Textbox (Input Box) in AngularJS And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Check WordPress Plugin Dependencies
  2.   Laravel 6 Get All query string parameters
  3.   Angular 6 Templating Tutorial with Examples
  4.   Golang Float64s function - Math function
  5.   Sticky Social Media Floating Sidebar html
  6.   Laravel 6 group by month/year using Eloquent
  7.   Angular 9/8 Material Radio Button Examples
  8.   jquery Increment Animating Numbers Counting Up Example
  9.   Laravel 5.7 custom 404 Error Page Using Exception Handlers
  10.   Laravel Left join get last record of right table in MYSQL

Leave a Reply

Your email address will not be published. Required fields are marked *