I have defined a function in external js file. I am not able to use it in home.page.ts file. It is showing TypeError: Cannot read property functionName() of undefined error


  <script src="assets/multiLayerSource.js"></script>


var multiLayerSource;

var layersHT = ;

function SetLayerHT(arglayersHT) {

layersHT = arglayersHT;



import { Component } from ‘@angular/core’;
import { OnInit, Renderer, ViewChild } from ‘@angular/core’;
declare var multiLayerSource: any;
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
export class HomePage implements OnInit {
layersHTP: any = ;
constructor() {}

ngOnInit() {
this.layersHTP.push( ‘a’, ‘b’, ‘c’, ‘d’ );

It is showing error while trying to access SetLayerHT().
The error is :
TypeError: Cannot read property ‘SetLayerHT’ of undefined.

Please help.

Don’t u need to use the keyword export to export the function?