'ng-change function Calling on-load before selecting

Calling ng-change="changeStudentStatus();" function on-load, before selecting options.

<md-select ng-model="ctrl.newStudentStatus" ng-change="changeStudentStatus();" ng-if="ctrl.studentStatusList" >
   <md-option class="ss-options" ng-value="item.display_name" ng-repeat="item in ctrl.studentStatusList" ng-selected="item.id == ctrl.statusId">{{item.display_name}}</md-option>
</md-select> 

Script :

$scope.changeStudentStatus = function(){
     //some logic  
};

it should Call when use change the DropDown. whats wrong in my script



Solution 1:[1]

I solved by doing this:

    $scope.changeStudentStatus = function(){
          if($scope.ctrl.newStudentStatus)
          {
            //some logic  
          }
    };

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eduardo Leffa Abrantes