Skip to content
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

Merged
merged 1 commit into from
Aug 3, 2014
Merged

itemController property can also take a controller class directly. #5301

merged 1 commit into from
Aug 3, 2014

Conversation

blessanm86
Copy link

Updated the documentation for itemController.

This aims to implement the issue discussed at #5174

@rwjblue
Copy link
Member

rwjblue commented Aug 2, 2014

Lookin' pretty good, will need some tests before we can merge it.

@blessanm86
Copy link
Author

@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?

@rwjblue
Copy link
Member

rwjblue commented Aug 2, 2014

Hmm, I think it is a feature, so it should be flagged.

@stefanpenner
Copy link
Member

+1 but ya should be feature flagged.

@blessanm86
Copy link
Author

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
Copy link
Member

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).

@blessanm86
Copy link
Author

@rwjblue I've updated the documentation.

stefanpenner added a commit that referenced this pull request Aug 3, 2014
itemController property can also take a controller class directly.
@stefanpenner stefanpenner merged commit 0028744 into emberjs:master Aug 3, 2014
@tomdale
Copy link
Member

tomdale commented Dec 5, 2014

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.

@workmanw
Copy link

workmanw commented Dec 7, 2014

@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.

@tomdale
Copy link
Member

tomdale commented Dec 12, 2014

@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.)

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

Successfully merging this pull request may close these issues.

5 participants