Reputation: 6388
I have written custom events for mobile devices in jasmine, and I am trying to fire the events.
so instead of
angular.element()[0].click()
how may I trigger custom events and other events to trigger functions?
Upvotes: 2
Views: 1443
Reputation: 336
To add to the above post, you can pass a custom event (with extra data) by doing this:
angular.element().triggerHandler({
'type': 'my-custom-event-name',
'foo': 'bar'
});
Upvotes: 0
Reputation: 63179
This should work:
angular.element().triggerHandler('my-custom-event-name');
If you want to attach additional data to your event:
angular.element().triggerHandler('my-custom-event-name', {'foo': 'bar'});
Upvotes: 3