$scope.apply is not a function