zachsnow / ng-multi-transclude

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

Issues with ng-if and inputs #22

Open ederuiter opened 9 years ago

ederuiter commented 9 years ago

When using ng-if in combination with multi-transclude weird things can happen with inputs. I created a fiddle to reproduce the issue:

http://jsfiddle.net/v9kvfo73/3/

The first label / input is the one with multi-transclude, the second one is with the standard ng-transclude. Both have a div with an ng-if around the transcluded block.

When updating one of the inputs I expect the form to become dirty and the save button should be enabled. This works as expected for the standard ng-transclude, but not for the one inside the multi-transcluded block. Updating the first text box doesn't even clear the pristine state of the text box itself. However updating the second text box will also update the first text box. So it seems the binding has become one-way ..

zachsnow commented 9 years ago

Thanks for the report I'll check it out.

davecap commented 9 years ago

We had a similar issue, but it seems to be fixed in a previous version (0.1.2).

jercoh commented 9 years ago

It seems to happen from version 0.1.4 (works in 0.1.3 and under).

zachsnow commented 9 years ago

Thanks @davecap @jercoh.

zachsnow commented 9 years ago

In fact using multi-transclusion in this way won't work: we perform the transclusion eagerly, not upon each occurrence of ng-multi-transclude. Probably we will need to entirely rethink how the module works to allow this usecase. Ideally we would compile each block separately and link them only when the corresponding ng-multi-transclude is linked.

sloosch commented 9 years ago

Hi zachsnow, Thats exactly how i've done it with https://github.com/sloosch/decl-transclude . My simple module doesn't rely on $transclude instead it uses the compile-phase of a directive to get the templates and their names to later transclude and put it back together via $compile in the link phase:

<div some-directive decl-transclude> //grabs the content of the element in the compile phase
    <div decl-transclude-as="foo">bar</div> //declares a transclude with a name - will be grabbed by decl-transclude
   ....
</div>
//inside some-directive
<div class="some-directive">
...
    <div decl-transclude-from="foo"></div> //compiles the grabbed content in the appropriate scope
....
</div>
zachsnow commented 9 years ago

Hey @sloosch, very cool, I look forward to checking it out!