Angular & 之间的路由Laravel [英] Routing between Angular & Laravel
问题描述
我正在尝试使用 Angular 制作一个简单的应用程序,与 Laravel 5 集成并在路由应用程序视图时遇到问题.
I am trying to make a simple App in Angular , integration with Laravel 5 and facing issues while routing the application views.
Routes.php
如下所示:
<?php
Route::get('/', function () {
return view('index');
});
在 Routes.php 中,我只在应用程序加载时第一次处理.
in Routes.php, i am handling only first time when application loads.
但在那之后我想通过 Angular 处理所有路由.所以,我确实喜欢这个:
But after that i want to handle all routing by Angular. So, i did like this:
app.js
文件
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('');
});
但是当我访问 http://localhost:8000/#/login
时,它会抛出找不到 views/login.html
的错误.
But when i access http://localhost:8000/#/login
then it throws error that views/login.html
is not found.
- 我尝试在 Laravel 默认文件夹中制作
login.html
如下图
- 还尝试在根目录中制作
views/login.html
如下
但没有一个工作
推荐答案
您可以将此文件放在公共目录中.正如您在 https://laravel.com/docs/5.3/structure#the-public-directory
You can put this files inside the public directory. As you can see in https://laravel.com/docs/5.3/structure#the-public-directory
这篇关于Angular & 之间的路由Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!