Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ng-click #42

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

Closed
ShaneChesnutt wants to merge 1 commit into GoTeamEpsilon:master from ShaneChesnutt:master
Closed

ng-click #42

ShaneChesnutt wants to merge 1 commit into GoTeamEpsilon:master from ShaneChesnutt:master

Conversation

@ShaneChesnutt
Copy link
Contributor

@ShaneChesnutt ShaneChesnutt commented Dec 12, 2016

No description provided.

Copy link
Member

MatthewVita commented Dec 12, 2016
edited
Loading

@ShaneChesnutt actually you need to add the following to your example:

constructor(props) {
 super(props);
 // TODO: express this in terms of Redux (Shane, you can leave this todo in for now. Will get to it later)
 this.state = {
 foo: 'bar'
 };
 
 this.clickHandler = this.clickHandler.bind(this);
}
clickHandler() {
 console.log(this.state.foo); // => 'bar'
}

Copy link
Member

Can add a note saying "you'll need to bind the click handler to the class so that the this context (and, therefore, the component state) is accessible.

Copy link
Member

MatthewVita commented Dec 12, 2016
edited
Loading

@ShaneChesnutt you're going to kill me, but I just realized one more thing we need to document with this section... how do you pass in the target data member with the click handler? For example, let's say you have the following data structure:

[{
 first: 'john',
 last: 'doe',
 email: 'john@doe.com'
}, {
 first: 'Mary',
 last: 'doe',
 email: 'mary@doe.com'
}]

and you ng-repeat it with an <button ng-click='vm.edit(row)'>edit</button> for each row, how does vm.edit function know which array item to set row.editMode = true for. We know this is rather easy in angular by looking for the index of the item in the larger array, but how would this work in React?

Copy link
Contributor Author

ShaneChesnutt commented Dec 12, 2016 via email

Okay I'll make sure to add that in
...
On Sun, Dec 11, 2016, 10:04 PM Matthew Vita ***@***.***> wrote: @ShaneChesnutt <https://github.com/ShaneChesnutt> you're going to kill me, but I just realized one more thing we need to document with this section... how do you pass in the target data member with the click handler? For example, let's say you have the following data structure: [{ first: 'john', last: 'doe', email: ***@***.***' }, { first: 'Mary', last: 'doe', email: ***@***.***' }] and you ng-repeat it with an <button ng-click='vm.edit(row)>editfor edit row, how doesvm.editfunction know which array item to setrow.editMode = true` for. We know this is rather easy in angular by looking for the index of the item in the larger array, but how would this work in React? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#42 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AE9XHq974m1oO3awaPuLHjgeDMkKb0Mwks5rHLmngaJpZM4LKIeA> .
MatthewVita reacted with hooray emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /