jQuery trigger equivalent in AngularJS
angularjs, javascript, jquery
Solution
AngularJS has jqLite built into it. Refer the docs to see the available methods
Angular jqLite
For your scenario:
`$` will not work in angularJS, `angular.element` is the equivalent of `$`. but jqLite being very limited does not support "selectors by id" meaning you cannot simply use `angular.element` to select an element by class or id like
var element = angular.element('#foo')
you have to use the following
var element = angular.element(document.querySelector('#foo'))
You may ask, "why not use document.getElementById('#foo')?" but remember we are using jqLite so we have to use `angular.element` in order to be able to use the jqLite methods on the element.
You can use the `.triggerHandler()` instead of `.trigger()`. jQuery triggerHandler docs
jqLite does not support `click()`. The workaround would be to use `.ready()`
element.ready(function() {
console.log('Click');
});
Problem
I am using AngularJS in my project and I don't want to include jQuery. I want to perform jQuery equivalent of this in AngularJS ``` $('.someclass').trigger('create'); ``` I searched in internet but couldn't find one.