This time I will bring you AngularJSGetting focus and operating focus. What are the precautions for AngularJS to get focus and operating focus. Here are practical cases, let’s take a look.
<!DOCTYPE html> <html ng-app="formExample"> <head> <meta charset="UTF-8"> <title></title> <script src="../js/angular.js"></script> <script> angular.module('formExample', []) .controller('FormController', ['$scope', function($scope) { $scope.userType = 'guest'; $scope.change = false; }]); </script> </head> <body> <form name="myForm" ng-controller="FormController"> userType: <input name="input" ng-model="userType" ng-blur="change=true" ng-focus="change=false" required> <span class="error" ng-show="myForm.input.$error.required && change">必填项</span><br> </form> </body> </html>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to set the BootStrap title to prohibit crossing lines
js controls the time to move every second
parabola.js implements parabola and add to shopping cart functions
The above is the detailed content of AngularJS gets focus and manipulates focus. For more information, please follow other related articles on the PHP Chinese website!