Search code examples
angularbootstrap-modalangular-bootstrapngx-bootstrap

Updating view in angular after modal closes


Using Angular 5, what I want to do is update an attribute in the parent component as soon as the child component (modal dialog) is closed. Are all three of these methods viable ways of doing this? And which would be the fastest/least overhead?

Option a: So far I've always used a Subject() in a singular Service instance that I call in the modal component as it closes and subscribe to in the parent component to listen when it is called and thus update my attribute.

Option b: Would an EventEmitter be a viable option for this? I'm guessing I emit just about any value when the modal closes and in the parent onChange I can reevaluate my attribute?

Option c: I looked into Angular Lifecycle hooks and found things like ngOnChanges() and ngDoCheck() but neither of those seem to be useful. Are there other hooks that could be usable for this situation?


Solution

  • Option B is fasted and least overhead.