In a separate file called constants.ts
, I have several string constants defined like this:
export const MY_PLACEHOLDER: string = 'some placeholder';
When working on an Angular2 component template, I need to utilize the MY_PLACEHOLDER
constant in this manner:
<input ... [placeholder]=MY_PLACEHOLDER />
To achieve this, I currently import the constant in my my-component.ts
file as shown below:
import {MY_PLACEHOLDER} from './constants'
and then proceed to use it within the template file.
Although this approach works smoothly, I encounter a tslint warning stating that "MY_PLACEHOLDER"
is an unused property whenever I repeat this process for each constant.
Is there a way for me to reference or utilize these external constants within the template file without triggering this warning?
EDIT: I am aware that I can disable the tslint warning if needed.