我采用BreezeJS Angular Q,它询问是否某些代码可以在app.run()函数中运行。
> app.config()
> app.run()
>指令的编译函数(如果他们在dom中找到)
> app.controller()
>指令的链接功能(再次,如果发现)
这里有一个simple demo,你可以看到每一个执行(和实验,如果你想)。
Run blocks – get executed after the injector is created and are
used to kickstart the
application. Only instances and constants can be injected into run blocks. This is to prevent
further system configuration during application run time.Run blocks are the closest thing in Angular to the main method. A run
block is the code which needs to run to kickstart the application. It
is executed after all of the service have been configured and the
injector has been created. Run blocks typically contain code which is
hard to unit-test,and for this reason should be declared in isolated
modules,so that they can be ignored in the unit-tests.
使用运行块的一种情况是在authentications期间。