Friday, 15 August 2014

angularjs - on Element Click get Its Details like html id -



angularjs - on Element Click get Its Details like html id -

i new angular js. please help me.

my html code

<span ng-repeat="item in items" class="spanclass" ng-click="spanclicked($event)">{{item}} </span>

and cotroller code is

mymodule.controller("mycontroller", function ($scope) { $scope.items = ["saurabh", "ram", "punit", "andhul", "shroraj", "toni"]; $scope.spanclicked = function (event) { //here want details of span element html, id , other //element. }});

can utilize 'this' intead of $event . if yes please allow me know how can accomplish goal.

thanks in advance.

you can utilize event.target element triggered event. can utilize angular.element(event.target).attr('id') id , other info.

angularjs angularjs-directive angularjs-ng-repeat

No comments:

Post a Comment