angularjs - Angular $compile with required controller -


I have a composite list command - it's a list item that can be a list of itself.
Parental defines the Directive Controller:

 . Directive ('parent', function () {controller: function ($ scope)}, link: function (scope, element, etter) {}})  

list (items) The parent controller is required to work properly by itself (why it should not be ..):

  .directive ('list', function () {required: 'parent' , Link: function (scope, element, attrs, parentCtrl) {}})  

Also goes for the same solid item, which is also OK:

 < Code> .directive ('item', function () {required: '^ parent', link An item can be a composite form, in which case this "list" itself creates the structure  The function (scope, element, attrs, parentCtrl) {}})  

$ Compile (ING) is done by a list item inside the link function:

  link: function (scope, element, etter, parent CTRL). $ Collection (" ") (scope) ...}  

which throws an exception:
< Em> Controller ', is not necessary for' direct 'list!

The reason for this is clear - $ Compilation does not provide function controls and therefore 'parental requirement' can not be solved.
And so I tried to make the controller available manually:

  $ compile (" gt >") ( Scope, empty, {'parent': parentCtrl});  

Which does not thrown an exception, but this time the controller does not provide it when needed.

Any ideas how the $ compile function should accept an external controller that should also be evaluated?

I had a similar problem, and the solution was to add the element to the parent first, and then To compile is.

  .directive (replace 'Gtc: parent'): true, link: function (scope, element, etter, parent CTLL) {scope.addSubList = function () {var sublist = Angular.element ('& lt; ul list & gt;') element.find ('a') .append (sublist); $ compiler (scublist);}}}};});  

See this plunker:


Comments