I have a variable in my angular 6 code, I'd like this variable to be set on document ready. How can I use angular var in JQuery?
export class AppComponent implements OnInit {
public myVar : string = "blue";
public ngOnInit()
{
$(document).ready(function(){
var ev = $('DivClassName');
var txt = ev.html();
if (txt == this.myVar)
{
ev.css("background-color", this.myVar);
this.myVar = txt;
}
});
} // ngOnInit
}
In this case I get this error in editor:
Property 'myVar' does not exist on type 'HTMLElement'.ts(2339)
EDIT: actually, I want to change background-color for each event depends on event-type in my app https://stackblitz.com/edit/angular-q14jh3