如何延迟从 $scope.$emit
获取的值并在页面加载后显示它?我有这个功能:
$scope.ActiveMenu = function (number)
{
$scope.selectedLink = number;
$scope.$emit('onAccountMenuSelection', $scope.selectedLink);
}
在我的其他 Controller 上:
$rootScope.$on('onAccountMenuSelection', _onAccountMenuSelection);
现在我将值从一个页面发送到另一个页面,但它总是先执行...那么我如何设置该值最后执行?
最佳答案
在 $timeout
上执行 $emit
,这将在下一个摘要周期运行代码。
$timeout(function(){
$scope.$emit('onAccountMenuSelection', $scope.selectedLink);
})
关于javascript - 如何在最后加载$scope.$?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31140605/