Improve this Doc

Error: $timeout:badprom
Non-$timeout promise

`$timeout.cancel()` called with a promise that was not generated by `$timeout()`.

Description

This error occurs when calling $timeout.cancel() with a promise that was not generated by the $timeout service. This can, for example, happen when calling then()/catch() on the returned promise, which creates a new promise, and pass that new promise to $timeout.cancel().

Example of incorrect usage that leads to this error:

var promise = $timeout(doSomething, 1000).then(doSomethingElse);
$timeout.cancel(promise);

To fix the example above, keep a reference to the promise returned by $timeout() and pass that to $timeout.cancel():

var promise = $timeout(doSomething, 1000);
var newPromise = promise.then(doSomethingElse);
$timeout.cancel(promise);