1

I have a demo site running on Laravel as Back-end and Jquery on front and was attempting to migrate Jquery to Angular JS. I was trying to achieve this using Laravel as routing and as a service for AngularJS. But this way I can't get variables on through URI on Angular (at least I couldn't find any way). Example:

http://localhost/estudio_php/user/perfil/1/edit

Angular Controller:

app.controller('estudioPerfilCtrl', function($scope, uiGmapGoogleMapApi, estudioService) {
$scope.loading = true;

//Issue here, getEdit(1) to get data from id = 1, need to get URI variable value
estudioService.getEdit(1).then(function(response) {...}

Laravel Routing

Route::group(array('prefix' => 'estudio'), function(){

//auth
Route::group(array('middleware' => 'auth'), function(){
    Route::group(array('prefix' => 'ajax'), function(){
        Route::get ('{id}/edit',                    'Estudio\PerfilController@editAjax');
    });

    Route::get ('{id}/edit',                'Estudio\PerfilController@edit');

The /ajax/edit route feeds data to Angular Service, and the /edit loads Laravel view, that calls Angular Controller.

Should I migrate all routing to AngularJS? Or is there a work around for my problem?

1
  • 1
    The great thing about using Laravel routes is being able to apply middleware to some routes and not others. If you did Angular routing your middleware would have to apply to every Angular route (assuming you would be doing a single-page angular application). To answer your other question (workaround): way to pass URI variable to an Angular view: stackoverflow.com/questions/29246298/… Commented Jan 4, 2016 at 20:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.