-
Couldn't load subscription status.
- Fork 12
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
ng-click #42
Conversation
@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' }
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.
@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?
1110535 to
f8826e4
Compare
No description provided.