Archimedes Pelican

Angular.js and Pelican

Learn More About It    

While this example looks pretty boring, it's what's going on under the hood that counts. The controller is incrementing a large number once per second, and a watch is set up on that large number variable in two places: the controller, and the directive.

Watching the large number variable from the controller is easy, since the variable is already in the scope and accessible to the watch function.

Watching the large number variable from the directive is more tricky; because the directive scope is a subset of the controller scope, not every variable will be available to the directive. This requires the use of attributes to pass variables through from the controller scope to the directive scope.

Once this is done, the directive can listen for changes to a variable in the controller. This is a crucial piece of infrastructure if you need to load large CSV or JSON files, and have the directives drawing plots from those large data files wait until the data has been loaded. In that case, you are loading/processing the data in the controller, but implementing watchers on the data in the directives.
Watched variable, from controller:
[[ controllerlabel ]]
Watched variable, from directive:
[[ directivelabel ]]

 

Made with by charlesreid1.