我在 index.html 的script标签中有一个函数,并且在index.html hideAppLoader()中有一个角度应用程序组件。我想在应用程序启动时调用该函数。我试过了,@Output但这不起作用。这是代码
索引.html
<head>
<script>
function hideAppLoader() { debugger;}
</script>
</head>
<body>
<my-app (onAppLoad)="hideAppLoader($event)"></my-app>
</body>
并在ts文件中
@Output() onAppLoad = new EventEmitter();
ngOnInit() {
this.onAppLoad.emit();
}
但即使控制台上没有错误,该函数也不会被调用。我什至尝试(onAppLoad)="this.hideAppLoader($event)"过(onAppLoad)="window.hideAppLoader($event)"
加载时,解决方案是什么,甚至可以从 Angular 组件调用纯 js 函数?