Submit or execute function

102 views
Skip to first unread message

Jean-Sébastien Ney

unread,
Oct 5, 2012, 12:04:25 PM10/5/12
to ang...@googlegroups.com
Hi,

Is it possible, in a form with many inputs, when i am on one of the input i want to run a specific function, when i am on another, i just want to normally submit the form.
or should do this with ui angular or jquery ?

thanks.

Abdul Azeez Shaik

unread,
Oct 5, 2012, 12:21:33 PM10/5/12
to ang...@googlegroups.com
You can use ng-change event on these input fields to call respective functions. If you can provide more details, will be able to give you exact code for that.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Jean-Sébastien Ney

unread,
Oct 8, 2012, 5:02:45 AM10/8/12
to ang...@googlegroups.com
Thanks Abdul, i was aware about `ng-change` but it does not allow me type `enter` while editing the input field without submit the whole form. Does it ?

ganaraj p r

unread,
Oct 8, 2012, 5:28:34 AM10/8/12
to ang...@googlegroups.com
If you dont want it to submit the form, you could use something like this 

<div blah blah blah .... ng-change="onChange($event)">......


in your controller 



$scope.onChange = function($event){

     $event.preventDefault();
     .....

}


--
Regards,
Ganaraj P R

Jean-Sébastien Ney

unread,
Oct 8, 2012, 9:47:33 AM10/8/12
to ang...@googlegroups.com
By doing this, $event parameter isn't defined in my controller's function.
Anyway, by hitting `enter`, `ng-change` function doesn't seem be fired. only `ng-submit`

Jean-Sébastien Ney

unread,
Oct 8, 2012, 9:56:25 AM10/8/12
to ang...@googlegroups.com
regarding the api documentation, $event seems to be only available for the following directives :

Reply all
Reply to author
Forward
0 new messages