How to achieve this condition (ng-change = "myFunction ($ event)") in AngularJS

I've searched a lot.

here are the links i found but i couldn't solve my problem.

Passing arguments to invoke the ngChange call from an internal directive

AngularJS - Why doesn't $ event on change exist for select dropdown

I have a simple function defined in a scope like this:

  app.controller('MyCtrl', ['$scope', '$sce', function ($scope, $sce) {
        $scope.MyFunction = function($event) {
                 // do stuff
        };
    }]);

      

And I have this html

<div ng-app="MyApp" id="ngApp" ng-controller="MyCtrl" style="display:none">
 <select class="form-control" name="selectedShowVariantsOption" ng-model="selectedShowVariantsOption" ng-options="option.name for option in options" ng-change="MyFunction($event)"></select>
</div>

      

I understand that in AngularJS you cannot pass $ event to ng-change in select. However, you can do it with a click. I still don't understand what is the reason for this? also any work to pass the $ event on ng change?

Any suggestion is greatly appreciated.

+3


source to share





All Articles