Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Wrong order of rendered elements when using ng-repeat, ng-if, and a directive #14326

Open
thatkookooguy opened this issue Mar 27, 2016 · 4 comments

Comments

@thatkookooguy
Copy link

Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?
BUG

What is the current behavior?
Order of rendered DOM is messed-up.

Currently, I get:

1
2
3
Printed twice, but should not
Printed twice, but should not
Printed twice, but should not

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
http://plnkr.co/edit/0KpEwgW8P2p00UfTYH6e?p=preview

What is the expected behavior?
The expected output should be:

1
Printed twice, but should not
2
Printed twice, but should not
3
Printed twice, but should not

What is the motivation / use case for changing the behavior?
This behaviour is confusing and isn't expected

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
tried this on angular 1.4.7 up to 1.5.0. happens on all of them

Other information (e.g. stacktraces, related issues, suggestions how to fix)
This is probably related to #6006 .

@lgalfaso
Copy link
Contributor

This is another variation of the fact that directives that do transclude: element are not supported in the top-level element of a templateURL of directives that do replace: true. I would like to tell you that there is an easy solution, but fixing this would involve an overhaul on how $compile works, and I do not see this happening soon.

@jeremypele
Copy link

jeremypele commented Apr 19, 2016

I had the same issue. Needed to move the ng-if condition on the directive element itself to 'fix' it

@wesleycho
Copy link
Contributor

I thought replace: true was deprecated? This issue can probably be closed given that it is not likely to be fixed due to the complexity of issues involving its usage, and there being a more than adequate workaround by just not using it & structuring HTML appropriately.

@gkalpak
Copy link
Member

gkalpak commented Nov 28, 2016

👍 We should document this as a known issue in the guide or in $compile API docs and close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants