Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.


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

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...