#using @if automatically gives error

15 messages · Page 1 of 1 (latest)

soft canopy
#

Hello, show your code directly, it'll help to understand.

cosmic hazel
#

@if (true) { }

#

`<div>

<form class="example-form">
<mat-form-field class="example-full-width">
<mat-label>Email</mat-label>
<input type="email" matInput placeholder="Ex. [email protected]">
<mat-hint>Errors appear instantly!</mat-hint>
@if (emailFormControl.hasError('email') && !emailFormControl.hasError('required')) {
<mat-error>Please enter a valid email address</mat-error>
}
@if (emailFormControl.hasError('required')) {
<mat-error>Email is <strong>required</strong></mat-error>
}
</mat-form-field>
</form>

</div>`

this is what i started with but i just started deleting html until i got to the root of the problem. being left with @if{} still leaves the same invalid eof error

soft canopy
#

By copying it in the Stackblitz example of the link you provided it works.

Try to restart ng serve

cosmic hazel
#

really?

#

yeah i already tried a restart

#

pasting in another component also gives me the same error

soft canopy
#

What's the Angular version of your project?

cosmic hazel
#

16 should have started with that my bad

soft canopy
cosmic hazel
#

welp thatll do it

#

theres literally a version choice on this website

#

im just dumb, disregard

#

thanks for the help