Skip to main content

Posts

Showing posts from 2017

Accessing Enum in template–Angular with Typescript

By reading title of  this post, It  seems some what misleading. In Angular 2 (or higher version for that matter). We cannot directly access  Enum or any other type for that matter into template. so, for an example  consider following example now if we try to access Enum WeekDays in HTML template as follows It would be resulted in runtime error shown below To resolve this error we should be assigning enum to component property as shown below. Reason behind this is , Component is the execution context for an Angular application. We can reference only those properties in template which are defined in component or have scope in component.