zachsnow / ng-multi-transclude

ng-multi-transclude
MIT License
79 stars 19 forks source link

TypeError: object is not a function #5

Closed AlexCppns closed 10 years ago

AlexCppns commented 10 years ago

at link (.../assets/angular_js/fancyinput_library/multi-transclude.js?body=1:51:41)

It seems to crash when trying to display the error:

 'ngMultiTransclude')('orphan',
                        'Illegal use of ngMultiTransclude directive in the template! ' +
                            'No parent directive that requires a transclusion found. '
                    );

I am not sure what that error means even... </noob>

AlexCppns commented 10 years ago

Update: I think the problem is that it doesnt work in a ng-repeat.

Update2: Ok so the problem is that I use other directives in the transclusion, eg:

 <a ng-multi-transclude="acfi-view-more" data-ng-if="searchBoxData.noResultDisplay == true" class="no-results" ></a>

won't work...

Update 3: Replacing ng-if by ng-show fixed it. Still unsure how to use transclusion inside a ng-repeat.

zachsnow commented 10 years ago

Hey Alex, apologies for the delayed response I was without connectivity for some time. I'll look into it, but I'm guessing that using both ng-multi-transclude and ng-if won't work due to the requirement that transclusion be used only once on an element. There's an internal method for allowing multiple different transclusions on a single element that Angular uses to allow ng-if to be used with ng-repeat; I'll see if I can get that to work.

zachsnow commented 10 years ago

As for using transclusion inside an ng-repeat, you should simply be able to move the transcluding directive onto an element within the repeat:

<ul>
    <li ng-repeat="thing in things">
        <a ng-some-transluding-directive>...</a>
    </li>
</ul>

Not great, as you end up with 1 wrapper element per transcluding directive, but it works. Perhaps I'm misunderstanding the issue you are facing though?

AlexCppns commented 10 years ago

@zachsnow I solved it that way (see my comment on the answer):

http://stackoverflow.com/questions/20129060/angular-js-directive-transclude-ngrepeat-error/20212631#comment37614872_20212631

I noticed that your library breaks that method by the way. I cannot use both at once. I used to have a plunkr about it somewhere... I lost it I think.

zachsnow commented 10 years ago

I guess I don't understand what you're trying to accomplish, but I'm glad you sorted something out. Cheers.

AlexCppns commented 10 years ago

@zachsnow This is exactly what I was trying to do:

http://jsfiddle.net/jt4Y2/16/

If there is a way to make it work with ng-multi-transclude. I ll be glad to hear it :).

By the way the error I have shown in my first post is a real bug.

zachsnow commented 10 years ago

Ah, ok. So you would like to place your "block to be filled" within an ng-repeat, so that it is filled multiple times, and each time it is filled it is rendered relative to the context in which it is found.

That's not how I initially thought of ng-multi-transclude being used, but it would be pretty awesome. I'll have a look.

zachsnow commented 10 years ago

Re: real bug, got it and a fix will be pushed tonight, should have been more clear; my apologies!

zachsnow commented 10 years ago

Closing this, relevant details for the transclusion issue have been added to #8.