• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Angularjs Events

Joined
May 27, 2008
Messages
3,629 (0.58/day)
System Name Ultra 64
Processor NEC VR4300 (MIPS R4300i)
Motherboard proprietary design
Cooling Fanless aircooled
Memory 4.5MB 250 MHz RDRAM
Video Card(s) 62.5 MHz Reality Coprocessor
Storage 32 - 512 Mbit ROM Cartridge
Display(s) 720x576
Case Clear Blue Funtastic
Audio Device(s) 16-bit CD quality
Power Supply proprietary design
Mouse N64 mouse for use with N64DD
Keyboard N64 keyboard for use with N64DD
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.
 
Back
Top