-
Notifications
You must be signed in to change notification settings - Fork 67
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
How does event handling work #24
Comments
Well, you can't use Vue events from a Vue component that's within an AngularJS one, because you're in AngularJS context. You have to bind event callbacks as props. Here's an example:
class HelloController {
constructor($scope) {
this.$scope = $scope;
this.handleClick = this.handleClick.bind(this);
}
handleClick(whateverArg) {
// Don't forget to use $scope.$apply in case you need to update model data
this.$scope.$apply(() => { ... });
}
}
<vue-component name="Hello" vprops-on-click="$ctrl.handleClick"></vue-component>
<script>
export default {
props: {
onClick: Function
},
...
methods: {
whateverMethod() {
this.onClick(this.whateverArg);
}
}
};
</script> Hope this helps ;-) |
Thank, I will try it out. If I am successful, I will open a PR to merge this intel into the docs! |
Done. Please review PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First off, thank you for this very cool piece of software!
I am kind of stuck on how I would handle a simple click event with ngVue.
I can not find anything about this in the docs.
How is the data flow from the vue component upwards to the angular controller meant to work?
The text was updated successfully, but these errors were encountered: