控制器中角度选择不更新的模型

时间:2016-08-18 11:48:23

标签: angularjs select ng-options

我试图在控制器中获取$ scope.selectedBranch但它没有更新。如果我在HTML中使用$ scope.selectedBranch它可以正常工作。

<select ng-model="selectedBranch" ng-change="onBranchChange()"  ng-options="branch for  branch in data.branches"
  

所有   

$scope.onBranchChange= function(){
    console.log($scope.selectedBranch)  
};


data = {"branches" : ["343dfds","dfdf43","sdfsd","sadser343"]}

1 个答案:

答案 0 :(得分:0)

使用数据前缀$ scope。 它应该如下:

$scope.data = {"branches" : ["343dfds","dfdf43","sdfsd","sadser343"]}