sa_1130
sa_1130

Reputation: 133

Is there a way to use typescript variable in html files?

How can I use a variable defined in a typescript file of a component, in my index.html file in angular 4?

Upvotes: 0

Views: 10418

Answers (1)

Hrishikesh Kale
Hrishikesh Kale

Reputation: 6548

you cannot use this in index.html directly but you can use this by assigning the value in a component.ts file like

yourvariable : string;

and use this variable only in a component.html file which is been of the same type.

like {{yourvariable}}

you can also access this variable to any component.

in angular index.html is the starting point of view in which there is component based div structure. you can add variable there using above procedure.

Upvotes: 3

Related Questions