Como puedo llamar una función javascript de un archivo propio con funciones desde un componente de angular.
Yo cargo desde el index.html el archivo jcc.js con mis funciones inclusives esta JFecha()
Me arroja el siguiente error:
ERROR in src/app/components/footer/footer.component.ts(15,17): error TS2304: Cannot find name 'JFecha'.
Mí código:
// tslint:disable-next-line: quotemark
import { Component, OnInit } from "@angular/core";
@Component({
// tslint:disable-next-line: quotemark
selector: "app-footer",
// tslint:disable-next-line: quotemark
templateUrl: "./footer.component.html",
// tslint:disable-next-line: quotemark
styleUrls: ["./footer.component.css"]
})
export class FooterComponent {
anio: string;
constructor() {
this.anio = JFecha();
}
}
El HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>julio.corbaz@gmail.com</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="assets/js/jcc.js"></script>
</head>
<body>
<app-root></app-root>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
</script>
</body>
Nota: JFecha es una funcion mia propia de un archivo js que se encuentra en
assets/js/jcc.js