ngChange没有从模型中获取更改

时间:2015-06-18 17:12:11

标签: angularjs select ng-options

我试图从我的控制器中的select访问obj,但我最终得到的唯一的东西是null和undefined。

        <select
        ng-change="watchActions(part)" 
        ng-options="part.serial as part.description for part in rawBaList.items" 
        ng-model="currentChose"
        ></select>

             $scope.currentChose = null;

             $scope.watchActions = function (obj) {
                  console.log($scope.currentChose);
                  console.log(obj);
              };

                $scope.$watch('currentChose', function (newValue, oldValue) {
                    if(newValue){
                        console.log("here the new value goes");
                    }
                });

以下是数据的前缀:

{
count: 2,
items: [
{serial: 2, description: 'here is some description'},
{serial: 24, description: 'some other description'}
]
}

1 个答案:

答案 0 :(得分:0)

这是一个范围问题,$ parent.currentChose修复了它

相关问题