Reputation: 1
I'm building a single page application using Angular2 and the Limitless layout. However, there is an app.js file in the theme that contains all the jQuery functionality. I have loaded it in the index.html but the jQuery only works when I refresh the page.
How can I modify the app.js to make the jQuery function inside run in every component?
Upvotes: 0
Views: 375
Reputation: 3008
Before the Component Decorator, use
// You can use $ to refer to jQuery inside the code
declare var $ : any;
@Component({
selector: 'my-selector',
providers: []
})
Upvotes: 0
Reputation: 2068
create function in app.js
ie.
function executeEveryCompo(){
console.log('Something');
}
and in every component AfterviewInit
add
ngAfterviewInit(){
executeEveryCompo();
}
dont forget to add declare var executeEveryCompo:any;
at the top of component
Upvotes: 0