2

I am trying to make a simple App in Angular , integration with Laravel 5 and facing issues while routing the application views.

Routes.php looks like as below:

<?php

Route::get('/', function () {
    return view('index');
});

in Routes.php, i am handling only first time when application loads.

But after that i want to handle all routing by Angular. So, i did like this:

app.js file

var membershipModule = angular.module('membershipModule', ['ngMaterial','ngRoute']);

membershipModule.config(function($routeProvider, $locationProvider, $mdThemingProvider){

    $mdThemingProvider.theme('default').primaryPalette().accentPalette('blue-grey');

    $routeProvider
        .when('/login', {
            controller: 'LoginController',
            templateUrl: 'views/login.html'
        })
        .when('/register', {
            controller: 'RegisterController',
            templateUrl: 'views/register.html'
        })
        .otherwise({redirectTo: "/"});
        $locationProvider.hashPrefix('');
});

But when i access http://localhost:8000/#/login then it throws error that views/login.html is not found.

  • I tried making login.html in Laravel Default Folder as below screen

enter image description here

  • Also Tried making views/login.html in root dir as below

enter image description here

but none of it is working

4
  • One question: why are you using PHP framework when you wish to use static HTML templates? And resources/views is not Laravel default frontend directory. That would be public. Commented Jan 5, 2017 at 11:57
  • @Gags, It is difficult to manage, batter than you can make api's in laravel and develop front end in separate angular Commented Jan 5, 2017 at 12:13
  • @DainisAbols i am not using static html. This is just to try the things out. Commented Jan 5, 2017 at 12:35
  • @Irfan APIs i can create. But routing is the main issue that is going wrong. If i can not control routing of laravel from angular then i dont see any use if using angular. Commented Jan 5, 2017 at 12:37

1 Answer 1

2

You can put this files inside the public directory. As you can see in https://laravel.com/docs/5.3/structure#the-public-directory

Sign up to request clarification or add additional context in comments.

2 Comments

Can i control menu in angular but get it from laravel?
Do you want to get your's html static files from Laravel, rigth? So you can create a "views" folder inside the public directory and place your's html files inside.

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.