Angularjs ngChange没有从模型中获取更改
我试图从控制器中的select访问obj,但最终得到的唯一结果是null和未定义Angularjs ngChange没有从模型中获取更改,angularjs,select,ng-options,Angularjs,Select,Ng Options,我试图从控制器中的select访问obj,但最终得到的唯一结果是null和未定义 <select ng-change="watchActions(part)" ng-options="part.serial as part.description for part in rawBaList.items" ng-model="currentChose" ></select>
<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");
}
});
这是一个范围问题,$parent.currentChoice修复了它您能在plunkr中重现这个问题吗?有问题的打字错误,或者您缺少了
ng model=“currentChoice
?我想我们缺少了一些东西。我重新创建了您在这里给出的:.$scope.$watch正在运行查找(检查控制台)。谢谢,我没有提到它是指令的一部分,并且ngModel无法看到控制器的范围,因此解决方案是添加$parent.CurrentChoice
{
count: 2,
items: [
{serial: 2, description: 'here is some description'},
{serial: 24, description: 'some other description'}
]
}