javascript - transcluded content requires the controller of the transcluding directive -
I have an instruction that separates its content. And there is a directive in the in-kind content which requires the controller of reciprocal instructions. It throws an error if I am creating a transclude function in reciprocal instructions. I think this is because transcycled content is cloned when you provide a transaction function ().
I also have a planker describing my problem:
What I want to do is I want to separate the contents and pars all ingredients in it and then I want to keep it in the right place. Collect and compile yourself in the DOM. The content that is transmitted is actually the configuration for my instructions.
I have also tried to evacuate the cloned arrays received at the reciprocal function, because in fact I do not need the content, I need to parse it and then manually change it later Will happen. Angular does not need to do anything with my different material but it does not work because the instructions are already recognized when the transsexual function is called. So when I empty the array I get an error ().
Merciful,
donation
>: "^ Controller" is required, then you are saying Kongra that the directors need to be attached to an ancestor DOM, the controller
is the element that runs the link function at that time. goes.
When you draw conclusions without the use of ngTransclude directive, transvoind methods are passed near your parent directive link function. (You already knew that it is for completeness.) It follows the following types of method:
- Removes content for removal
- if A password was passed by a
clone attachment
, clone attachefany - Call
$ compile ()
using the given radius (or Clone content) to compile and link
If you transase the call, and the content Mr. do not engage as a descendant of an element, then to pass it (a new range meets the $ guardian of default directive scoop). If necessary controller (or not add content to all in the DOM), then the content will not have any parent with the necessary controller. Because this can not get the necessary controller, you get an error.
If you use KABA with : "^ kmFoo"
, then you have descended from the DOM nodes kmFoo to transcluded content.
Easiest fix () and add, but it has to go ahead immediately and engage in the element of kmFoo for the purposes of compiling $.
Separate (in contrast) maintains click handler, etc., so if you add this element later, everything will continue to work if you are using the early versions of AngularJS , Then you may have to add jQuery to add it separately because it was not included in the initial versions.
Here is a snippet put together
app.directive ('kmFoo', function () {return {restricted: 'A', scope: true, Template: '& lt; div & gt; & lt; / div & gt;', transclude: true, controller: function () {// ...}, link: function (scope, $ element, attrs, ctrl , TranscludeFn) {console.log ('linking foo'); // We can temporarily add it to the $ element so that it will be added, // but after that it is linked, we can separate it separately (scope, Function (clone) {console.log ('transcluding foo'); $ element.append (clone) c = clone;}) .. different (); // & lt; - immediately it Separate}};}); ('' KB '', function () {return: 'A', scope: true, is required: '^ km fu', link: function (radius, $ element, attr, futctl) {console.log (' Linking bar '); // is still a child of the element with Kim Fu, // but this method will not be complete. // You can postpone this element to add DOM // until you And you can keep it wherever you want.}};});
Comments
Post a Comment