Angular JS ng-change事件未启动

时间:2017-08-02 19:53:37

标签: javascript html angularjs

这是我的代码示例

<select ng-model="selectedProdTeam" 
    ng-options="team for team in prodTeams | orderBy" 
    ng-change="getRolesBasedOnSelectedTeamProd()">
    <option value="">Select Teams</option>
</select>

JS

$scope.getRolesBasedOnSelectedTeamProd = function(){
    if($scope.selectedProdTeam != null || $scope.selectedProdTeam !=undefined){ 
        $scope.prodRoles = $scope.prodResp.$scope.selectedProdTeam;
    }
}

1 个答案:

答案 0 :(得分:0)

应该是,

fflush(stdin)

修改

您的orderBy过滤器应该使用参数或删除过滤器。

<select ng-model="selectedProdTeam" ng-options="team for team in prodTeams | orderBy" ng-change="getRolesBasedOnSelectedTeamProd()">
 <option value="">Select Teams</option>
</select>

<强> ex | orderBy:'name'"

DEMO
angular.module("myApp", [])
  .controller("myCtrl", function ($scope) {
   $scope.prodTeams = [
    { 'name':'Chelsea',
      'id':1
    },
    { 'name':'UK',
      'id':2
    }
   ];
   $scope.getRolesBasedOnSelectedTeamProd = function(){
    alert('fired');
   }
  });