-.html
<input type="text" ng-focus="display = false" ng-blur="display = true" ng-init="display = true">
<p ng-show="display">aaa</p>
As shown in the above code, focus/blur can normally control the display and hiding of p tags
-.html
<input type="text" ng-focus="display = false" ng-blur="hide()" ng-init="display = true">
<p ng-show="display">aaa</p>
-controller.js
$scope.hide = function (){
$scope.display = true;
};
As long as the input is focused in the above code, the display is always false. Please solve it.
Continued:
I was convinced and posted the project code as follows:
-.html
<p class="form-group">
<label class="form-label">应用名:</label>
<span class="desc" ng-show="applyTips"
ng-init="applyTips = true"> 应用名是您将要创建的应用的名称,组织内唯一</span>
<span class="warn" ng-show="applyNameExit">应用名已存在,请重新输入</span>
<span class="warn" ng-show="login.applyName.$error.pattern">您的应用名不正确</span>
<p class="controls">
<input type="text" name="applyName" class="form-control"
ng-model="param.deployment.metadata.name"
ng-pattern="/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/" ng-focus="applyTips=false"
ng-blur="login.applyName.$error.pattern ? applyTips = false : nameIsExit();"
required>
</p>
</p>
-controller.js
$scope.nameIsExit = function (){
if($scope.param.deployment.metadata.name !='' && $scope.param.deployment.metadata.name != undefined){
var param = {
orgId: $localStorage.orgId,
userId: $localStorage.userId,
sessionId: $localStorage.sessionId,
"name": $scope.param.deployment.metadata.name
};
deploymentService.applyNameisExit(param, function(res){
if(res.code == 1415){
$scope.applyTips = false;
$scope.applyNameExit = true;
$scope.submit = function(){
return;
}
}else{
$scope.applyTips = true;
$scope.applyNameExit = false;
}
});
}
else{
$scope.applyTips = true;
}
};
After the input loses focus, the prompt information will no longer be displayed.
ng-blur Just write the expression in it
ng-blur="isHide"
Assign a value to isHide in the controller
$scope.isHide=true;
The same is true in ng-focus
Official website documentation
This young man, I suspect there is something wrong with your posture.
如果还有问题,我保证让你自切jj
---------------------------------Hehehe---------------- -----------------------
Open the console and check the error message to solve the problem.