我用的是角$watch,如。
基于触发器selectedIndex值的更改。
$scope.selectedIndex = 1;
Trigger.onReceivingTriger($scope,function(data){
$scope.selectedIndex = 0;
});
$scope.$watch('selectedIndex', function(){
console.log("am watching");
});
我期望一旦触发值设置,手表就能正常工作。但问题是,只有在我单击屏幕上的一些内容后,$watch才能工作。我被困住了听到..。任何帮助请..。
发布于 2015-04-18 18:31:10
在使用事件更新角外的作用域时,您应该运行摘要周期。您需要通过执行$scope.$apply()
来消化周期
码
Trigger.onReceivingTriger($scope,function(data){
$scope.selectedIndex = 0;
$scope.$apply();
});
https://stackoverflow.com/questions/29721075
复制相似问题