Javascript 角度:Ng仅在窗体中关闭输入字段时显示

Javascript 角度:Ng仅在窗体中关闭输入字段时显示,javascript,html,angularjs,Javascript,Html,Angularjs,具体问题在我的电子邮件输入字段中 是否可以仅在验证字段后且用户不在输入字段内时显示ng show消息 换句话说,如果用户在输入字段上,我希望ng show消息消失 我尝试了多种逻辑组合,但都未能成功: (函数(角度){ "严格使用",; angular.module('formExample',[]) .controller('ExampleController',['$scope',function$scope){ $scope.master={}; $scope.update=函数(用户)

具体问题在我的电子邮件输入字段中
是否可以仅在验证字段后且用户不在输入字段内时显示ng show消息

换句话说,如果用户在输入字段上,我希望ng show消息消失

我尝试了多种逻辑组合,但都未能成功:

(函数(角度){
"严格使用",;
angular.module('formExample',[])
.controller('ExampleController',['$scope',function$scope){
$scope.master={};
$scope.update=函数(用户){
$scope.master=angular.copy(用户);
};
$scope.reset=函数(形式){
如有需要(表格){
形式:$setPristine();
表单。$setUntouched();
}
$scope.user=angular.copy($scope.master);
};
$scope.reset();
}]);
})(窗口角度)

姓名:

告诉我们你的名字。 电邮:
告诉我们你的电子邮件。 这不是一封有效的电子邮件。
您可以使用ngFocusngBlur指令来实现所需的结果

只需在ngFocus上设置一些变量false,在ngBlur上设置true,然后将该变量添加到ngShow条件中

 <input type="email" ng-model="user.email" name="uEmail" required="" ng-focus="showEmailValidationMsg = false;" ng-blur="showEmailValidationMsg = true;"/>
    <br />
    <div ng-show="(form.$submitted || form.uEmail.$touched) && showEmailValidationMsg">
      <span ng-show="form.uEmail.$error.required" style="background:red;">Tell us your email.</span>
      <span ng-show="form.uEmail.$error.email"style="background:red;">This is not a valid email.</span>
    </div>


告诉我们你的电子邮件。 这不是一封有效的电子邮件。

这里正在工作…

您可以使用ngFocusngBlur指令来实现所需的结果

只需在ngFocus上设置一些变量false,在ngBlur上设置true,然后将该变量添加到ngShow条件中

 <input type="email" ng-model="user.email" name="uEmail" required="" ng-focus="showEmailValidationMsg = false;" ng-blur="showEmailValidationMsg = true;"/>
    <br />
    <div ng-show="(form.$submitted || form.uEmail.$touched) && showEmailValidationMsg">
      <span ng-show="form.uEmail.$error.required" style="background:red;">Tell us your email.</span>
      <span ng-show="form.uEmail.$error.email"style="background:red;">This is not a valid email.</span>
    </div>


告诉我们你的电子邮件。 这不是一封有效的电子邮件。

这里是工作…

可能重复的我尝试了那些解决方案,不幸的是,我没有得到想要的结果,也许我错过了一些经过深思熟虑的东西。可能重复的我尝试了那些解决方案,不幸的是,我没有得到想要的结果,也许我错过了一些东西