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
angularjs


source to share


No one has answered this question yet

See similar questions:

13
Passing arguments to call the ngChange event from an internal directive
five
AngularJS - Why choose drop down doesn't have $ event on change

or similar:

1690
How does data binding work in AngularJS?
1195
How do I access the $ scope variable in the browser console using AngularJS?
1073
How to use $ scope. $ Watch and $ scope. $ Apply in AngularJS?
658
How do search engines work with AngularJS apps?
582
How to bind to a list of checkbox values ​​using AngularJS?
582
How to iterate over keys and values ​​using ng-repeat in AngularJS?
476
AngularJS ngClass conditional
404
How to use keypress event in AngularJS?
258
getting ng object selected with ng-change
1
Shift change event on model change



All Articles
Loading...
X
Show
Funny
Dev
Pics