This is my complete code, sorry i dont know how to publish plunker.
$event is undefined.
<!DOCTYPE html>
<html ng-app="plunker">
<head>
</head>
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<ul>
<li ng-repeat="child in collection">
<child child="child"></child>
</li>
</ul>
</body>
</html>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.collection = [{
id: 1,
name: 'node one',
}, {
id: 2,
name: 'node two',
}, {
id: 3,
name: 'node three',
}, ]
});
app.directive('child', function() {
return {
restrict: 'E',
replace: true,
scope: {
child: '='
},
template: '<span ng-click="showGroup($event)">{{ child.name }}</span>',
link: function(scope, element, attrs) {
scope.showGroup = function(group_id) {
alert($event.target);
}
}
}
});
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.