Saturday, March 9, 2019

How to call your own Javascript Function from Angular 4 Typescript Application


To call your own JavaScript Function from Angular 4 Typescript Application follow this technique.

In file .angular-cli.json

      "scripts": [
        "../node_modules/adam-scripts/core.js"
      ],

The core.js file contains this function.

function ShowMessage(inMessage) {
    alert(inMessage);
}

In the Typescript file refer and call it like this.

declare var ShowMessage: any;

  ngOnInit() {
    ShowMessage('Working');
  }


No comments:

Post a Comment

All Blogs so far ...