Fix $scope.$apply() error