我正在使用Angular2和无限布局构建一个单页面应用程序。但是,主题中有一个包含所有jQuery功能的app.js文件。我已经将它加载到index.html中,但是jQuery只有在我刷新页面时才能工作。
如何修改app.js以使内部的jQuery函数在每个组件中运行?
发布于 2017-02-02 17:13:43
在app.js ie中创建函数。
function executeEveryCompo(){
console.log('Something');
}并在每个组件AfterviewInit中添加
ngAfterviewInit(){
executeEveryCompo();
}别忘了在组件顶部添加declare var executeEveryCompo:any;
发布于 2017-02-02 17:14:35
在组件装饰器之前,使用
// You can use $ to refer to jQuery inside the code
declare var $ : any;
@Component({
selector: 'my-selector',
providers: []
})https://stackoverflow.com/questions/41997828
复制相似问题