我有 global.js 脚本文件,需要在路由更改为“/home”时启动 InitSwiper() 函数,但找不到如何在脚本文件中跟踪路由器或通过 home.component.ts 启动函数
import { Component, OnInit } from '@angular/core';
declare var global: any;
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
ngOnInit() {
global.initSwiper();
}
}
global.js
$(function () {
"use strict";
$(window).load(function(){
pageCalculations();
$('#loader-wrapper').fadeOut();
$('body').addClass('loaded');
initSwiper();
});
...
})