use $scope.$apply() to update the ui change