Modal.fromTemplateUrl('templates/modal.html', function(modal) {
$scope.addSlideModal = modal;
}, {
// Use our scope for the scope of the modal to keep it simple
scope: $scope,
// The animation we want to use for the modal entrance
animation: 'slide-in-up'
});
I can clear the model using $scope.addslide but i still cant access the form using $scope.form_add_slide. Anyone have any idea how to access form in modal? I want to use some validation when submitting the form.
I see, I guess I was wrong about name doing something, it’s tied to the <form> directive.
In this case, I think your best bet is to put an ng-controller on the Modal itself, and then process the form validation and stuff inside the modal controller, only passing data to the parent scope when you are done. What happens when you pass in a scope to the modal controller is that it is inherited, so technically it is the child not the parent.
The alternative is to iterate the child scopes, which is not recommended but could work: http://jsfiddle.net/Lv7Wr/
I’ve had a similar issue when trying to get the form controller published into the parent scope as indicated in the AngularJS docs. The problem is that you most likely have this form sitting inside one of Ionic’s directives (like content, tab, nav-view, etc). Since these directives create their own scopes the form controller is likely getting published into one of those since it is the immediate parent (rather than your controller’s scope being the immediate parent). One way that I have worked around this is to add both the name="blah" and ng-controller="blahCtrl" to the form element. So for your case set the ng-controller attribute on the form to the same name as the controller where you are calling Modal from.
Here is the solution:
In your function you have to pass your form name as parameter to your function to catch it in order to clear it:::
“< f o r m n a m e =“f o r m _a d d _ s l i d e” n g- s u b m i t =“createSlide(addslide,form_add_slide)”>”
$scope.createSlide = function(slide,yourForm) {
// save is success
// clear your form here form like => yourForm.$setPristine();
=> yourForm.$setUntouched();
}