Currently, I am engaged in an Angular project where I am implementing a feature to add objects to a table. However, not all of the object's fields are considered valid, and I need to notify the user through alerts. I am facing an issue where, after dismissing the alerts once, they fail to reappear...
<span *ngIf="errorMessage!=null && errorMessage!=''" name="errorSpan" class="alert alert-warning alert-dismissible msg" role="alert">
<strong>{{errorMessage}}</strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span></button>
</span>
Here is the code in TypeScript (TS):
errorMessage:string;
isWorkerValid():boolean{
this.errorMessage="";
if(this.workerInserted.id==null || this.workerInserted.id=="" || this.workerInserted.id.length<9 || this.workerInserted.id.length>9){
this.errorMessage+="מספר הזהות של העובד אינו תקין"+"\n";
}
if(this.workerInserted.name==null || this.workerInserted.name==""){
this.errorMessage+="שם העובד אינו תקין"+"\n";
}
if(this.errorMessage!=""){
return false;
}
return true;
}
I have experimented with ng-show
- unfortunately, it did not resolve my issue. I also attempted using
dang-click="errorMessage=''"
and ng-click="errorMessage=''"
. However, I am restricted from leveraging JavaScript in my Angular project, which means I am unable to implement solutions like $scope.hideAlert()=function(){ $scope.serverError = false; }
as suggested in a previous answer here.
Even after dismissing the alert once, it refuses to reappear when triggered again. Can anyone offer assistance with this problem?