Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在AngularJS中的模糊事件之后重新聚焦输入字段_Javascript_Html_Angularjs - Fatal编程技术网

Javascript 在AngularJS中的模糊事件之后重新聚焦输入字段

Javascript 在AngularJS中的模糊事件之后重新聚焦输入字段,javascript,html,angularjs,Javascript,Html,Angularjs,我有一个html输入字段,无论发生什么事,我都想专注于它。我知道如何用JQuery实现它,但我只想在真正需要时嵌入它。我的代码示例不起作用 到目前为止,我对代码的想法是: HTML 我希望你们有正确的灵感或更好的解决方案来解决这个问题:)您可以通过以下指令保持元素的焦点: angular.module('test',[]).directive('stayFocused',function(){ 返回{ 链接:函数($scope$element){ $element.on('blur',func

我有一个html输入字段,无论发生什么事,我都想专注于它。我知道如何用JQuery实现它,但我只想在真正需要时嵌入它。我的代码示例不起作用

到目前为止,我对代码的想法是:

HTML


我希望你们有正确的灵感或更好的解决方案来解决这个问题:)

您可以通过以下指令保持元素的焦点:

angular.module('test',[]).directive('stayFocused',function(){
返回{
链接:函数($scope$element){
$element.on('blur',function(){
$element[0]。焦点();
});
}
};
});

弗斯特

第二
<input type="text" ng-blur="refocus()" autofocus>
$scope.refocus = function($scope, $element) {
    $element.focus();
};