I have designed a page with a button that uses an ng-template together with the ionicModal service,
I have my AppCtrl as the controller of my entire page (Applied to the tag), and a button in that body uses the ionicModal to show a modal.
very similar to the given formula here
In my modal “send” button I use ng-click to call a method in my controller.
What happens is as follows:
before showing the modal, every value in my scope which is binded to the ui in my modal, is received ok and I can have the appropriate start point
when “send” is clicked, the called method tries to create an object of the variables in the scope (which were binded to my modal’s components), and there, the values I see are those I had before the modal was opened, not those he changed.
Its like its getting a copy of my scope, and not the scope itself.
How can I either give my modal its own controller and read values from it, or have everyone the same scope?
this is how I instantiate the modal in my controller:
Hi Aaron, Im sorry to say but I have no CodePen account.
I did however created a small example to demonstrate my issue, tough im not at home, but I took the given modal example in ionic website and modified it to demonstrate.
As you can see in the code below, in my modal window Im binding to an object an it shows in the modal, but when I hide it, since the scope of the modal is an isolated scope, all the changes are lost for the parent scope.
Im new to ionic & Angular, I watched all the videos in thinkster.io but obviously there are some holes need to be filled. Im not quite sure if that is the correct approach to this type of issue.
My intent is to show a modal where I fill in details that when I close it, I build a new object out of it. will it be simpler if I have another controller just for my modal?
Edit: I also thought of having an entire different controller for my modal, which is fine by me, to have its logic there, but I have trouble handling the show/hide of it, because the ‘X’ button in the modal will need to activate the ‘hide()’ which is located in my first controller.