The javascript function (help) below is not being called from ngOnInit()?
In web console: ERROR ReferenceError: "help is not defined"
Would you know how this can be done?
src/assets/myjs.js:
function help() {
console.log("hilfe");
}
src/app/highlight.directive.ts:
import { Directive, ElementRef, OnInit } from '@angular/core';
declare function help() : any;
@Directive({
selector: '[appHighlight]'
})
export class HighlightDirective implements OnInit {
constructor(el: ElementRef) {
el.nativeElement.style.backgroundColor = 'yellow';
}
ngOnInit() {
help();
}
}
angular.json:
...
"styles": [
"src/styles.css"
],
"scripts": [
"src/assets/myjs.js"
],
},
...