foundation-apps icon indicating copy to clipboard operation
foundation-apps copied to clipboard

Rendering another directive inside foundation-apps directives

Open 34r7h opened this issue 9 years ago • 12 comments

I don't think this is related to #596 and forgive me if this issue was already brought up. I'm want to inject ng-map map directive inside the zurb accordian directive. Doing so creates the space for the map but doesn't render the map. If I take the same code outside the directive it will work. Any ideas of what to try?

here's my repo if it helps: https://github.com/irthos/medviz

Thank you!

34r7h avatar Apr 23 '15 01:04 34r7h

Do you get any JavaScript errors?

gakimball avatar Apr 23 '15 01:04 gakimball

thanks.. no javascript errors in the browser console. the inspector shows the map directive being there but not rendering the map tiles.

34r7h avatar Apr 23 '15 02:04 34r7h

Confirming... none of the angular directories work inside zf-* directories I tried to use simple ng-repeat, ng-click and etc. inside zf-tabs (no luck). Console doesn't provide any errors since it's simply missing a $scope data, looks like zf directories are using it's own scope.

playnox avatar Jul 09 '15 16:07 playnox

I'm having the same issue with the tabs directive. A similar issue was observed with the zf-iconic directive (#569) and was resolved with change cce52b4aef7b49ac9d07ff60c85d700ce4fe6af8. I'm seeing the same root cause in that the directives are not copied to the element, though I'm not sure if it's the same issue. I think the problem revolves around the usage of transclude in the tabs. I think a solution similar to the one I used for developing the interchange directives might be needed (https://github.com/zurb/foundation-apps/pull/549/files). I'll play around with it for awhile and see what I can figure out.

soumak77 avatar Jul 27 '15 13:07 soumak77

The tabs are transclusion hell! The attribute issue was part, but not the whole story. The root problem is that all tab trancludes are done during the post link operation on the element. The post link of an element occurs after all children elements have been post linked. What this means is, any directives within a tab are being run before the raw content is transcluded into the tab causing angular to be unaware that a directive exists within the tab.

As I mentioned, transferring attributes is another issue with the tabs. This can be fixed similar to cce52b4aef7b49ac9d07ff60c85d700ce4fe6af8, however, it must be noted that if directives are used on the same element as the zf-tab directive, the zf-tab directive will need to be recompiled after copying the attributes. If the directives are used in children of the zf-tab directive, no recompile will needed as children directives will be compiled after the zf-tab directive once the tab directives are fixed to transclude the correct data.

soumak77 avatar Jul 27 '15 16:07 soumak77

Is there a solution for this? I am having this problem as well and it is really annoying indeed. I would like to use directives inside zf-tabs, but they don't work (and they don't even throw any errors). Of course I can write my own directives for tabs, but this makes zf-tabs completely useless.

gaboratorium avatar Apr 11 '16 19:04 gaboratorium

I have code like this, with components (sessions-one-list, sessions-group-list) and it works just fine with zf-tabs.

.main_section-aside-inner
    div.tabs_nav(zf-tabs="")
        div(zf-tab="", title="1:1 SESSIONS" ng-mousedown="$ctrl.changeLink(true)")
            sessions-one-list(
                mom="$parent.$ctrl.mom",
                one="$parent.$ctrl.sessionsOne.present",
                one-past="$parent.$ctrl.sessionsOne.past"
                active-edit-session="$parent.$ctrl.activeEditSession"
                show-modal="$parent.$ctrl.showModal"
            )
        div(zf-tab="", title="GROUP SESSIONS" ng-mousedown="$ctrl.changeLink(false)")
            sessions-group-list(
                mom="$parent.$ctrl.mom", 
                group="$parent.$ctrl.sessionsGroup.present",
                group-past="$parent.$ctrl.sessionsGroup.past",
            )

mrova avatar Apr 12 '16 08:04 mrova

I guess this plugin was written by some interns. maybe even whole foundation for apps!

paper-coffee avatar Jun 13 '16 16:06 paper-coffee

For anyone who is running into this issue, I was able to get around this by effectively changing this line from

element.append(tabContent);

to

element.append($compile(tabContent)(scope));

jf0rce avatar Jul 01 '16 18:07 jf0rce

+1 $compile ftw

34r7h avatar Jul 11 '16 16:07 34r7h

Using $parent should let you access to the parental scope outside of zf-tabs. It will be nice if the documentation is more clear on these details.

betommy23 avatar Jul 15 '16 16:07 betommy23

this issue with be addressed with https://github.com/base-apps/angular-base-apps/issues/24

soumak77 avatar Jul 25 '16 23:07 soumak77