-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Can't require a parent directive of an element with the same directive. #4518
Comments
repro -- It appears that It seems to be due to jqLite's implementation of |
Implement option to strengthen require '^' operator, by adding another '^'. When a second '^' is used, the controller will only search parent nodes for the matching controller, and will throw or return null if not found, depending on whether or not the requirement is optional. Closes angular#4518
I have yet to run into anyone who has done |
I tend to agree, but I think it should wait for some proper review, as there may be some use case that I'm oblivious to that depends on this behaviour (as unlikely as that may be) |
I tend to agree with Daniel on this, however I have seen 3rd party documentation written like: http://www.cheatography.com/proloser/cheat-sheets/angularjs/ Where it says ^ means "Look on parent elements too" |
Yeh, I've also got use-cases where it would be desirable to omit controllers on the same elements. If there are concerns about breaking changes we could have alternative syntax that would allow us to explicitly say that we want only controllers from a parent element (maybe |
Implement option to strengthen require '^' operator, by adding another '^'. When a second '^' is used, the controller will only search parent nodes for the matching controller, and will throw or return null if not found, depending on whether or not the requirement is optional. Closes angular#4518
It would be nice to get this fixed. IMO it should start with the parent. All the documentation states that '^' refers to parents. |
Yes, it would be, in the mean time you can get the parent controller like var cntrl = element.parent().inheritedData('$YOURCNTRLNAMEController') where YOURCNTRLNAME is whatever you named your controller. On Thu, Jul 17, 2014 at 9:38 AM, Andrew Collard [email protected]
|
+1 this would be nice! |
Implement option to strengthen require '^' operator, by adding another '^'. When a second '^' is used, the controller will only search parent nodes for the matching controller, and will throw or return null if not found, depending on whether or not the requirement is optional. Closes angular#4518
Implement option to strengthen require '^' operator, by adding another '^'. When a second '^' is used, the controller will only search parent nodes for the matching controller, and will throw or return null if not found, depending on whether or not the requirement is optional. Closes angular#4518
Implement option to strengthen require '^' operator, by adding another '^'. When a second '^' is used, the controller will only search parent nodes for the matching controller, and will throw or return null if not found, depending on whether or not the requirement is optional. Closes angular#4518
Implement option to strengthen require '^' operator, by adding another '^'. When a second '^' is used, the controller will only search parent nodes for the matching controller, and will throw or return null if not found, depending on whether or not the requirement is optional. Closes angular#4518
Just as the
ngForm
directive is able to be nested and communicate with parentngForm
controllers, there should be a clear method to optionally require a parent directive in the case where the current element contains the same directive. Currently, arequire
value of^?myDir
will result in the current controller being injected into thelink
function of themyDir
directive. It would be very helpful if arequire
value such as^^?myDir
would ignore the current element/controller and use the same methodology used in thengForm
directive, effectively:element.parent().controller( 'myDir' );
.The text was updated successfully, but these errors were encountered: