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

ng-include breaks ng-click #4354

Closed
corelgott opened this issue Oct 9, 2013 · 9 comments
Closed

ng-include breaks ng-click #4354

corelgott opened this issue Oct 9, 2013 · 9 comments
Milestone

Comments

@corelgott
Copy link

Having ng-include and ng-click on the same element, kills the ng-click-handler

<div ng-include src="'template'" ng-click="snort();" ng-repeat="item in data"></div>

See: http://plnkr.co/edit/nEIi3U

@zachsnow
Copy link
Contributor

zachsnow commented Oct 9, 2013

The priority of ng-include changed recently, and its "manual" transclusion system was removed, so ng-repeat + ng-include on the same element isn't going to work anymore (that's not what you are seeing, as it didn't make it into rc2, just a heads up).

5eb1fb6

http://plnkr.co/edit/qUnwgX?p=preview

@petebacondarwin
Copy link
Contributor

See this comment: #3584 (comment). Number 4 is the important item here.

@corelgott
Copy link
Author

Ah i see… Seems kind of logical that since the element is getting removed, click may not work.

But it's kind of strange, that is breaks the existing behavior. In 1.1.5 it works like I previously expected. (This was the reason for the ticket, since it broke while updating…) –

So even thought it's understandable behavior: Is this intended?
Or are there plans to "transport" the attributes from the ng-view element over to the resulting element? (And of course apply them)

@IgorMinar
Copy link
Contributor

this is fixed in master. check out http://plnkr.co/edit/qUnwgX?p=preview

@waterplea
Copy link

Seems to be not working again as my app with AngularJS 1.5.0 ng-click doesn't work on items with ng-inlcude as an attribute, just like in original post. Test:

{{test}}
<div ng-click="test = 'working'" ng-include="some.svg"></div>

@gkalpak
Copy link
Member

gkalpak commented Feb 16, 2016

@waterplea, I couldn't reproduce it. If you are still seeing a problem in v1.5.0, please open a new issue, posting a live demo of the issue (e.g. using CodePen, Plnkr etc). Thx !

@waterplea
Copy link

Thanks gkalpak, looks like some sort of scope issue on my side.

@poshest
Copy link
Contributor

poshest commented Mar 21, 2016

I've had this issue too, with 1.5.0-rc.0... ng-click on the same element as ng-include of an SVG. The click was changing the value of a template-local variable. The variable was changed, but that change couldn't be seen by the rest of the template... a scoping issue like @waterplea had.

@jnemeth
Copy link

jnemeth commented Feb 22, 2018

Lol, years later, this is still a thing. For those who stumble upon this, I recommend wrapping the element with the ng-include with the ng-click rather than putting it on the same element.

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

No branches or pull requests

8 participants