How can I use a variable defined in a typescript file of a component, in my index.html file in angular 4?
1 Answer
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.
<p>{{nameOfVariable}}</p><app-root></app-root>is called in yourindex.htmlyou cannot access any variables out of the app. Useapp.component.htmlinstead