0

I did not manage to get the event in parent controller. Tried lot of solutions but always get undefined

Also if I call to that function in link function and from there call to the controller it is not working (but print the object correct in the link function)

thx

Page:

<slider update-event="updateEvent(event)"></slider>

controller:

$scope.updateEvent= function(event) {
    console.log(event);
}

directive template:

<ul>
    <li  ng-click='updateEvent(event)' ng-repeat="event in events track by $index"><li>
</ul>

directive code:

restrict: "AE",
templateUrl: "s.html",
replace: true,
scope:{
  updateEvent: '&',
},
link: function (scope,element, attrs, ctrl) {
}
Icarus
  • 1,627
  • 7
  • 18
  • 32
Scopi
  • 663
  • 1
  • 6
  • 21

1 Answers1

0

Change your template to:

<ul>
    <li ng-click='updateEvent({event: event})' ng-repeat="event in events track by $index"><li>
</ul>

this should be enough (see here)

Dario
  • 6,152
  • 9
  • 39
  • 50