mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs: fix division by zero in progress events example (#46077)
If the `event.total` is undefined, this line would have generated a `NaN` due to division by zero. I suppose, that a `0` would be more suitable for this case. PR Close #46077
This commit is contained in:
committed by
Alex Rickabaugh
parent
3dec816276
commit
8ea4e1e6eb
@@ -62,7 +62,7 @@ export class UploaderService {
|
||||
|
||||
case HttpEventType.UploadProgress:
|
||||
// Compute and show the % done:
|
||||
const percentDone = Math.round(100 * event.loaded / (event.total ?? 0));
|
||||
const percentDone = event.total ? Math.round(100 * event.loaded / event.total) : 0;
|
||||
return `File "${file.name}" is ${percentDone}% uploaded.`;
|
||||
|
||||
case HttpEventType.Response:
|
||||
|
||||
Reference in New Issue
Block a user