-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
itemController property can also take a controller class directly. #5301
itemController property can also take a controller class directly. #5301
Conversation
Lookin' pretty good, will need some tests before we can merge it. |
@rwjblue Thanks for reviewing this. Will look into adding some tests. Can this pull request be considered as a bug fix or does it need to be a feature under a flag? |
Hmm, I think it is a feature, so it should be flagged. |
+1 but ya should be feature flagged. |
Feature flagged the code and test. Prefixed the commit and added an entry in the features json and md file. Is there anything else? @rwjblue @stefanpenner |
|
||
@property itemController | ||
@type String | ||
@type Ember.Controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be {String|Ember.Controller}
or something (to indicate that it accepts either).
@rwjblue I've updated the documentation. |
itemController property can also take a controller class directly.
At today's core team meeting, we decided to no-go this feature because we are deprecating item controllers and recommend users start migrating from item controllers to components. |
@tomdale et al I'd love to hear what the recommended pattern for this is. In our app, we have a few itemControllers that are really "helpers" for things like action handling and CP data transformation. They end up with a lot of reuse through out the app, but have different markup. Something like this: {{#each user in loggedInUsers itemController="user"}}
<label>Name:</label> {{user.displayName}}
<label>Last Login:</label> {{user.lastLogin}}
{{/each}} At first, I thought it might be something like this: {{#each user in loggedInUsers}}
{{#user-widget user=user}}
<label>Name:</label>{{controller.displayName}}
<label>Last Login:</label> {{user.lastLogin}}
{{/user-widget}}
{{/each}} But that leaves me with a conundrum, how do I access the component scope within the template? {{controller}} doesn't work, neither does {{view}}. Is there a way to do this? The same goes for action targets as well. Adding an {{action}} to the the user's displayName will always target the controller for the template's primary scope, not for the parent component. |
@workmanw Block params should solve this problem for you: {{#each user in loggedInUsers}}
{{#user-widget user=user as |component|}}}
<label>Name:</label>{{component.displayName}}
<label>Last Login:</label> {{user.lastLogin}}
{{/user-widget}}
{{/each}} (The component can yield whatever it wants into the block params, including itself.) |
Updated the documentation for itemController.
This aims to implement the issue discussed at #5174