Which is equivalent to $ (this) in AngularJS

I have this code in a view:

<span id="l3-bridge" ng-click="redirect('l3bridge')" class="menu-opt">
    <img class="marginleft" src="/web/bundles/lima3main/images/icon-l3bridge.png">
    L3 Bridge
</span>

And this is my redirection function in angular:

$scope.redirect = function(url) {

    var element = angular.element( $(this) );
    console.log(element);

}

What I need to do is get the id value (in this case l3-bridge ) from the element I clicked.

Is there any equivalent $(this).attr('id')from jQuery to AngularJS?

Edit: I mean, I need a view item id. How can I do this using angular?

+4
source share
1 answer

Pass the $ event event to the handler:

<span id="l3-bridge" ng-click="redirect($event, 'l3bridge')" class="menu-opt">
    <img class="marginleft" src="/web/bundles/lima3main/images/icon-l3bridge.png">
    L3 Bridge
</span>

$scope.redirect = function(obj, url) {

    var id = obj.target.attributes.id.value;

}
+4
source

Source: https://habr.com/ru/post/1546205/


All Articles