angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

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

Open thatkookooguy opened this issue 8 years ago • 4 comments

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 .

thatkookooguy avatar Mar 27 '16 10:03 thatkookooguy

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.

lgalfaso avatar Mar 28 '16 19:03 lgalfaso

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

jeremypele avatar Apr 19 '16 20:04 jeremypele

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.

wesleycho avatar Nov 27 '16 07:11 wesleycho

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

gkalpak avatar Nov 28 '16 08:11 gkalpak