From the provided information it seems that there is something wrong with your local project configuration.
I have further added the demonstrated code sample to the following StackBlitz example:
where it functions as expected.
Could you let us know if you are you using the official Angular cli tool to create the Angular project ?
Could I ask you to provide any additional details that may help us to locate the root of the issue. For example which version of the Angular framework are you using or anything else related to the project setup used on your side? Thank you. We are looking forward to your reply.
Progress is here for your business, like always. Read more
about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.