I have a Modal with a form in it, and I want to close it on successful submit.
I save the NgbModalRef as a class property on the open
method and im executing this code on submit:
(had to create the localModalRef
because of scope issues)
As soon as it gets to the close()
execution the console shouts:
localModalRef.close is not a function
Cant seem to figure out what have i done wrong.
Thanks in advance.
This should be posted on StackOverflow rather than here.
And you should always post your code as text, rather than as an image, since it makes it easier to read, copy and paste.
Anyway, you’re not initializing
this.modalRef
with the NgbModalRef (BTW, TypeScript should warn you about that, if you specify the type of themodalRef
property). You’re initializing it with the promise returned bythen()
on theresult
property ofNgbModalRef
.The code should be: