Handle cyclic dependencies

* The PR depends on #96.
* Please review only the second commit.
No, you are not missing anything, I just wanted to be sure. OK, 10 sounds
good than.

On Wed Oct 29 2014 at 2:26:43 PM Victor Savkin <notifications@github.com>
wrote:

> In modules/core/src/compiler/element_injector.js:
>
> > @@ -314,6 +317,10 @@ export class ElementInjector extends TreeNode {
> >    }
> >
> >    _new(binding:Binding) {
> > +    if (this._constructionCounter++ > _MAX_DIRECTIVE_CONSTRUCTION_COUNTER) {
>
> Since you can only request objects from an ancestor (Query is lazy, so it
> does not matter here), a cycle can exist only within an injector. Am I
> right?
>
> But even it were not the case, it would not matter. This is because every
> injector has its own counter. So for a cycle to exist, the same _new must
> be called an infinite number of times. As a result, it will eventually
> exceed 10 for all the involved injectors. When no cycle exists, _new will
> be called only once for every registered directive, and thus cannot be
> greater than 10 for every injector.
>
> I'm probably missing something. Can you provide an example where it won't
> work?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/angular/angular/pull/105/files#r19573573>.
>