Error message not showing for template-driven form validation?
up vote
0
down vote
favorite
Here's my code inside my .html
file:
<select class="form-control"
[(ngModel)]="profile"
name="profile" required
*ngIf="page.options == 1"
#profile="ngModel"
[ngClass]="{ ... }">
<!-- some code -->
</select>
<div *ngIf="profile?.invalid && (profile.dirty || profile.touched)" class="form-error">This field is required.</div>
What I'm encountering is that when I use *ngIf
for the element profile
, the error message doesn't become visible, but when I don't use *ngIf
, the validation error shows.
What could be the reason behind this?
forms validation angular6
add a comment |
up vote
0
down vote
favorite
Here's my code inside my .html
file:
<select class="form-control"
[(ngModel)]="profile"
name="profile" required
*ngIf="page.options == 1"
#profile="ngModel"
[ngClass]="{ ... }">
<!-- some code -->
</select>
<div *ngIf="profile?.invalid && (profile.dirty || profile.touched)" class="form-error">This field is required.</div>
What I'm encountering is that when I use *ngIf
for the element profile
, the error message doesn't become visible, but when I don't use *ngIf
, the validation error shows.
What could be the reason behind this?
forms validation angular6
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Here's my code inside my .html
file:
<select class="form-control"
[(ngModel)]="profile"
name="profile" required
*ngIf="page.options == 1"
#profile="ngModel"
[ngClass]="{ ... }">
<!-- some code -->
</select>
<div *ngIf="profile?.invalid && (profile.dirty || profile.touched)" class="form-error">This field is required.</div>
What I'm encountering is that when I use *ngIf
for the element profile
, the error message doesn't become visible, but when I don't use *ngIf
, the validation error shows.
What could be the reason behind this?
forms validation angular6
Here's my code inside my .html
file:
<select class="form-control"
[(ngModel)]="profile"
name="profile" required
*ngIf="page.options == 1"
#profile="ngModel"
[ngClass]="{ ... }">
<!-- some code -->
</select>
<div *ngIf="profile?.invalid && (profile.dirty || profile.touched)" class="form-error">This field is required.</div>
What I'm encountering is that when I use *ngIf
for the element profile
, the error message doesn't become visible, but when I don't use *ngIf
, the validation error shows.
What could be the reason behind this?
forms validation angular6
forms validation angular6
asked yesterday
herondale
14410
14410
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203675%2ferror-message-not-showing-for-template-driven-form-validation%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password