Erwin Erwin - 1 year ago 118
TypeScript Question

Is it possible to set variable javascript variables outside from angular2?

I am new to angular2 and used a component which is from other library and I want to pass a data from angular2 . My problem is that , I can't set the variable if its not from angular2 to that third party component.

Can anyone enlighten me if its possible?


//hmtl outside angular2
var somevar; //variable on somepage.html

//component from angular2
export class SomeComponent implements OnInit{

//id like to assign a value to somevar from inside this component
somevar = "blah blah";



Answer Source

hmtl outside angular2

window['SomeVarUpdated'] = function (newValue) {
  // do something

component from angular2

export class SomeComponent {
  constructor() {
    window['SomeVarUpdated']("blah blah");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download