本文介绍了Angular&之间的路由拉拉韦尔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Angular中创建一个简单的App,与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.

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&amp;之间的路由拉拉韦尔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 12:56
查看更多