javascript - Why does my directive lose $event? -
i have custom directive confirm if user clicks element wants perform action:
.directive('ngreallyclick', ['$modal', function ($modal) { return { restrict: 'a', scope: { ngreallyclick: "&", }, link: function (scope, element, attrs) { var isdeletedisabled = scope.ngreallydisabled; element.bind('click', function () { if (isdeletedisabled != true) { var message = attrs.ngreallymessage || "are sure ?"; ... var modalinstance = $modal.open({ template: modalhtml, controller: modalinstancectrl }); modalinstance.result.then(function () { scope.ngreallyclick({ ngreallyitem: scope.ngreallyitem }); //raise error : $digest in progress }, function () { //modal dismissed return false; }); }; }); } } }]);
it used e.g:
<a ng-really-message="are sure want save , close?" ng-really-click="saveandcloseglobal(456)"
where saveandcloseglobal
called when user confirms choice. but, if try , pass $event
function, original click
event, ends undefined. if use plain ng-click=saveandcloseglobal($event)
correct event object in saveandcloseglobal
.
Comments
Post a Comment