Laravel / Angular Routes $ routeProvider

0

I have something like this in the app.js of my application:

app.config( function( $routeProvider ) {
    $routeProvider.when('evento/:id/:caminho', {
        templateUrl: 'views/evento.html',
        controller: 'PrincipalEventoController'
    });
    $routeProvider.when('evento/:id/:caminho/sobre', {
        templateUrl: 'views/sobre.html',
        controller: 'SobreEventoController'
    });

Laravel's route is localhost:8000/evento/1/nome-do-evento . I have a div with ng-view on the page.

The problem is that the div with ng-view is not loading the content I want. Neither the view nor the controller defined in the app.js. Always give the message "Sorry, the page you are looking for could not be found". I think the solution is simple, but I'm not getting it and I decided to ask the help of the masters.

Embrace them all.

    
asked by anonymous 10.10.2015 / 14:21

1 answer

1

David,

Your design is wrong. The routes created in Laravel (PHP Framework) have nothing to do with the routes created with Angularjs (Framework Javascript), already established communication between Angular and Laravel is what happens.

In Laravel with Angular , the Html Views is created inside the public/html folder (or it can be any folder name within

If JavaScript (Angular) code would look like this:

app.config( function( $routeProvider ) 
{

    $routeProvider.when('evento/:id/:caminho', 
    {
        templateUrl: '/html/evento.html',
        controller: 'PrincipalEventoController'
    });

    $routeProvider.when('evento/:id/:caminho/sobre', 
    {
        templateUrl: '/html/sobre.html',
        controller: 'SobreEventoController'
    });

});

And your organization of folders would look like this:

Inthisimageitdemonstratesinsidethefolderpublictofoldercontrollerwiththe%htmlfiletags,thisbeinganexampleshowingthecorrectlocationofpublicofyourAngularapp

Yourlinktocallitemscreatedinlaravelwouldbe

<ahref="#/evento/1/caminho" aria-controls="evento" role="tab" data-toggle="tab">Eventos 1 Caminho</a>

Follow this example by changing html as I told you about the folder and run normally by creating a link as shown in the example ...

    
10.10.2015 / 15:53