Relationship between routes and form submission

1,891 views
Skip to first unread message

windchill

unread,
Jul 19, 2012, 2:37:33 PM7/19/12
to ang...@googlegroups.com
I'm new to Angular. 

I want to present a form and based up successful submission load a different view/partial. 

I can't seem to find any docs describing how to do this. Can someone enlighten me?


r...@hixfamily.org

unread,
Jul 19, 2012, 4:26:47 PM7/19/12
to ang...@googlegroups.com, r...@hixfamily.org
Wow!

Thanks for the reply but this is really confusing. How does it have anything to do with the $route service? 

I've read about submitting forms and about routes. I just want to know if there is a way to trigger a new route after a form has been successfully submitted.


On Thursday, July 19, 2012 12:56:16 PM UTC-6, Ricardo Bin wrote:
You can use events to do this.

Pawel Kozlowski

unread,
Jul 19, 2012, 4:35:37 PM7/19/12
to ang...@googlegroups.com
Hi!

On Thu, Jul 19, 2012 at 10:26 PM, <r...@hixfamily.org> wrote:

> I've read about submitting forms and about routes. I just want to know if
> there is a way to trigger a new route after a form has been successfully
> submitted.

I'm not sure what you mean by " a form has been successfully" as in
angular.js (or any other single-page, ajax-driven app) you would
simply send data via ajax request. Anyway, going back to your
question, you could use the $location service
(http://docs.angularjs.org/api/ng.$location) to manipulate a browser's
URL and thus trigger route navigation.

It would be really, really great if you could send a jsFiddle with a
code fragment with your use case (even if not working!). Without a
working (or broken!) example it is next to impossible to help
effectively.

Cheers,
Pawel

r...@hixfamily.org

unread,
Jul 20, 2012, 11:07:15 AM7/20/12
to ang...@googlegroups.com
Pawel,

Thanks for the response.

Your $location tip gave me some ideas but I'm afraid I still understand scoping very well. 

I have put together a jsfiddle that doesn't work but shows you what I'm thinking. 

Thanks for your help.

rob

Pawel Kozlowski

unread,
Jul 20, 2012, 3:16:37 PM7/20/12
to ang...@googlegroups.com
hi!

On Fri, Jul 20, 2012 at 5:07 PM, <r...@hixfamily.org> wrote:
> Pawel,
>
> Thanks for the response.
>
> Your $location tip gave me some ideas but I'm afraid I still understand
> scoping very well.
>
> I have put together a jsfiddle that doesn't work but shows you what I'm
> thinking.

OK, cool, jsFiddle definitively helps. One thing you should keep in
mind that you shouldn't use data-manipulation / Ajax URLs with route
URLs. Bad your example evolves in the right direction: you should send
your data via an Ajax request and based on the response received
update the $location.

Hope this helps,
Pawel

Pawel Kozlowski

unread,
Jul 20, 2012, 4:03:38 PM7/20/12
to ang...@googlegroups.com
hi again!

On Fri, Jul 20, 2012 at 9:59 PM, Rob Hicks <r...@hixfamily.org> wrote:
> Pawel,
>
> How do I get to the $location service in the success promise? See
> http://jsfiddle.net/robhicks/htHBQ/4/.
>
> $location is undefined.

Just relay on the closure scope: http://jsfiddle.net/htHBQ/5/

Cheers,
Pawel

Srikar Shastry

unread,
Oct 24, 2013, 11:22:46 PM10/24/13
to ang...@googlegroups.com
Is there a way for angular to stop its AJAX behavior and load the new page?
I just want to use angular for client side validation (check if field is not empty and input field follow patterns) and then, load a new page on submit.
I have a symfony framework on which my html and angularjs are a part as twig templates. Controller in symfony handles the routing of pages.
Now, the default html 5 form submit works:
<form name="step1" method="post" action="">
<input type="text" name="title">
<input type="text" name="fname">
<input type="text" name="lname">
<input type="text" name="company">
<input type="tel" name="phone">
<input type="submit" name="submit" value="Continue">
</form>

Just looking for angular's validation and on success, it should just let the symfony route work. (checkout action="").
How can i do that?
Reply all
Reply to author
Forward
0 new messages