Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use typescript in AngularJS to check the interpolation/binding in HTML

I know that TypeScript can detect compile errors for *.ts files.

However, what about getting these benefits in AngularJS views/templates? For example, if I have a code like:

<div ng-controller="HomeController as home">
    {{home.property1}}
</div>

And I have a HomeController class defined, then I'd like to receive a compile error if "property1" isn't defined for HomeController class.

Is anything like that possible?

like image 319
VitalyB Avatar asked Oct 20 '22 03:10

VitalyB


1 Answers

Is anything like that possible?

Possible : Yes. You will need to create your own HTML Parser and then integrate it with the TypeScript compiler (possibly using the TypeScript language service).

Existing : No.

like image 55
basarat Avatar answered Oct 22 '22 23:10

basarat