Max
Max

Reputation: 123

mdToast cannot resolve a promise with itself error

I keep running into an error in the console when my $mdToast fires. It says: TypeError: [$q:qcycle] Expected promise to be resolved with value other than itself '{}' The toast works fine, but I would prefer not to have that error whenever it pops up. Here is the function:

let showSuccess = this.mdToast.show({
        template: '<md-toast>User added successfully!</md-toast>',
        hideDelay: 33000,
        position: 'top'
    });

    this.mdToast.hide(showSuccess);

Does anyone know what might be causing this? Thanks

Upvotes: 1

Views: 477

Answers (1)

Tortila
Tortila

Reputation: 568

You don't need to pass toast itself to hide function. Just use it without any parameters:

this.mdToast.hide();

According to the reference it hides an existing toast. Optional response parameter is actually used for another purpose (promises).

$mdToast.hide([response]);

Hide an existing toast and resolve the promise returned from $mdToast.show().

Upvotes: 3

Related Questions