I am trying to call javascript function from the typescript function. This is not working at all.
I have created sudo code in stackblitz. Please check the same.
I am trying to call javascript function from the typescript function. This is not working at all.
I have created sudo code in stackblitz. Please check the same.
You can export it at one place, import it at another.
hello.js
export function hello() {
console.log('hello world');
}
app.component.ts
import { hello } from '../external/hello.js';
@Component({
// ...
})
export class AppComponent {
buttonClick() {
console.log('btn click called. 1.');
hello();
console.log('btn click called. 2.');
}
}
hello()for an external script"src/external/sample.js"...console.log(...)statement in thesample.jsfile outside of that function to ensure it gets loaded, it never gets called in Stackblitz.