You can enable binding expression validation explicitly by adding the compiler option fullTemplateTypeCheck in the “angularCompilerOptions” of the project’s tsconfig.json. It produces error messages when a type error is detected in a template binding expression.
For example, consider the following component:
1 2 3 4 5 6 7 |
@Component({ selector: 'my-component', template: '{{user.contacts.email}}' }) class MyComponent { user?: User; } |
This will produce the following error:
1 2 |
my.component.ts.MyComponent.html(1,1): : Property 'contacts' does not exist on type 'User'. Did you mean 'contact'? |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.