简体   繁体   中英

Angular 4 ng-bootstrap close Modal from child component

I am using ng-bootstrap' modal and got stuck with a problem.
Situation:- I have a form component that I am showing in a modal. Now, I want to close the modal once the user submits the form and backend confirms the success.
problem:- As guided here , I don't have a reference of the modal in child component to close it. please suggest a way. Thanks.

You could pass the modal reference to it using a child input property.

<child-component [parentRef]="ref">

And then in your child component you'll have to define something like:

@Input() ref;

Please take a look at the Angular documentation here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM