# `cancel` ( service in module `ng` )

## Description

Cancels a task associated with the `promise` . As a result of this the promise will be resolved with a rejection.

## Usage

    $timeout#cancel([promise]);

### Parameters

- `promise(optional) – {Promise=} –`

  Promise returned by the `$timeout` function.

### Returns

`{boolean}` –

Returns `true` if the task hasn't executed yet and was successfully canceled.