Routing between Angular & Laravel

烂漫一生 提交于 2019-12-11 05:49:33

问题


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

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

but none of it is working


回答1:


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



来源:https://stackoverflow.com/questions/41484457/routing-between-angular-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!