I received an html node and store it as angularjs element:
var el=angular.element(e.target);
How can i check if that element is of type "textarea" or "input" without using jQuery?
element is an alias for the jQuery function. If jQuery is not available, angular. element delegates to AngularJS's built-in subset of jQuery, called "jQuery lite" or jqLite. jqLite is a tiny, API-compatible subset of jQuery that allows AngularJS to manipulate the DOM in a cross-browser compatible way.
The ng-dblclick Directive in AngluarJS is used to apply custom behavior when an element is clicked double. It can be used to show or hide some element or it can popup an alert or change the color of text when it is clicked twice.
You can use document. getElementById() in Angularjs, but manipulating HTML in a controller is not a good practice. I recommend you to create a directive and do this kind of stuff there.
"How does this and $scope work in AngularJS controllers?" Short answer: this. When the controller constructor function is called, this is the controller. When a function defined on a $scope object is called, this is the "scope in effect when the function was called".
You can easily find it by using :-
el[0].tagName=="INPUT" or el[0].tagName=="TEXTAREA"
Small example:-
<div ng-controller="MyCtrl">
<input type="text" name="name" id="name"/><br>
<textarea id="check"></textarea>
</div>
Controller:-
var e1=angular.element(document.querySelector("#name"));
var e2=angular.element(document.querySelector("#check"))
console.log(e1[0].tagName);
console.log(e2[0].tagName);
Fiddle
A rather short answer is:
el[0].tagName === 'TEXTAREA'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With