Take sevice and directive references 3:grab any Services
We can grab a reference to any service using the injector
function of element where is ngApp
defined (or grab the $rootEleme NT manually if using angular ' s bootstrap method):
>Angularelement ( ' html ' ). Injector (). Get ( ' MyService ' ) -> object Span class= "p" >{undo: function redo: function_pushaction< Span class= "O" >: functionnewdocument: functioninit: function /span>
We can then call methods on this service just like we could if we injected it.
4:access Controller for directive
Some directives define a controller with certain additional (often shared) functionality. To access the instance of a controller for a given directive from the console, just use the controller()
function:
> angular.element(‘my-pages‘).controller()-> Constructor {}
The last one was more advanced and not used as frequently.