Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Need ability to remove messages without the controller or view changing #29

@martynchamberlin

Description

@martynchamberlin

Here's my case scenario: I'm building an upload feature. If the user selects a file with bad data, we show an error message and give them a chance to re-upload the file once they've addressed the changes. Once they start to re-upload the file, I need to be able to remove the error messages and start fresh.

The only way I can do that with this directive is to force the $rootScope.mcMessages message to change.

// function that gets triggered when user initiates upload
$scope.upload = function() { 
  // First, remove any errors that might have occurred from a previous upload attempt
   messageCenterService.reset();
   // Shouldn't have to explicitly do this next part but unfortunately I have to
   $rootScope.mcMessages = messageCenterService.mcMessages;

   // Parse the file

   if ( errors occurred ) {
     messageCenterService.add("danger", "Error occurred, please try again!");
     // Shouldn't have to explicitly do this next part but unfortunately I have to
     $rootScope.mcMessages = messageCenterService.mcMessages;
  }
}

I feel like the directive itself should be what's refreshing the $rootScope.mcMessages array. Why do I have to do this explicitly myself? Am I missing something here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions