Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

html - Problem with ng-if to check if input field is empty or not

I have an input tag..

<form name="patientSearchForm">

<input name="text" id="textType" type="text" class="form-control" /> 
                                                       
<button type="submit">Submit Form</button><br /><br />
                    
</form>                   

How to display the message that input field cant be empty using ng-if. I am using

<span style="color:Red" ng-if="!textType.value" ng-show="patientSearchForm.$submitted"> My message </span> 

But it is not working . Please help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this

<input name="text" id="textType" type="text" class="form-control" /> 
<span class="form-control-feedback" *ngIf="textType.value.length === 0">
My message message
</span>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...