php - Combining AngularJS and Symfony2 - routing and non-ajax page access -


this question consisted of 2 questions.

one being how can create amount of routes, other routes call 1 html page (basically, want symfony2 take in url's, else being left angularjs).

get_user:     path:     /api/getuser     defaults: { _controller: acmedemobundle:api:getuser } create_user:     path:     /api/createuser     defaults: { _controller: acmedemobundle:api:createuser } ... other:     path      [[ put in? ]]     defaults: { _controller: acmedemobundle:main:getpage } 

any url afterwards, angular should take in ngroute, through backends other route.

now second question have is, possible restrict routes (get_user, create_user...), except other route kind of call isn't ajax? know asp.net, want result of naming file _file.cshtml (you can't access directly, through ajax calls)

i'm not sure understand need.

you can create angularjs routes , write symfony2 routes on same or other url, not same method.

if want define route multiple url, can parameters uri parts, :

other     pattern:   /{first}/{page}     defaults:  {  _controller: acmedemobundle:api:getpage }     requirements:         first: keyword|secondkeyword         two:  \d+ 

in example, first argument of url can 1 of keywords, , second must validated regular expression.

then, if want restrict route ajax calls, use condition :

create_user:     path:     /api/createuser     defaults: { _controller: acmedemobundle:api:createuser }     condition: "request.isxmlhttprequest()" 

or restrict route specific method(s) :

create_user:     path:     /api/createuser     defaults: { _controller: acmedemobundle:api:createuser }     methods: post 

but think have define each route.


Comments