1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Angularjs Events

Discussion in 'Programming & Webmastering' started by ste2425, Mar 17, 2014.

  1. ste2425


    May 27, 2008
    3,577 (1.04/day)
    Thanks Received:
    Huddersfield, uk
    Ive created a single page application using nodeJs and angularJS. All my script files are loaded when the page is first loaded. My views are dynamically loaded using ng-view.

    This means that my controllers for all the different pages are instantiated even when the view for that page isn't loaded. Whilst this isn't a problem, may even make viewing the app better not having to wait for angular to bootstrap things up. I do have a problem with events that are being fired in my services.

    I have some RTI (Real Time Information, think I used to right abbreviations) pushing data periodically from the server which is then broadcast across my app using angularJS's $broadcast. Trouble is as my controllers are always instantiated there event listeners are firing when my service broadcasts. Even when the view is not loaded for them.

    Is there a way to stop this? It's not really a problem, and i could always look into lazy-loading i think its called of controllers. However i can see possible problems and was just wondering if there's a quick and easy solution to stop an event listener firing when the controllers corresponding view is not loaded.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)