Laravel 5 AngularJS html5Mode

前端之家收集整理的这篇文章主要介绍了Laravel 5 AngularJS html5Mode前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Laravel 5和AngularJS开发一个项目.我想启用 @H_403_1@$locationProvider.html5Mode(true);

并停止重新加载页面.当我将其设置为false并访问链接时,页面不会重新加载.

这是我的route.PHP

@H_403_1@Route::get('/',function () { return View::make('index'); });

角度代码

@H_403_1@app.config(function($routeProvider,$locationProvider) { $routeProvider.when('/',{ templateUrl: 'views/Feed.html',controller: 'fdController' }).when('/collections',{ templateUrl : 'views/collections.html',controller: 'clController' }).otherwise({ redirectTo : '/' }); $locationProvider.html5Mode(true); });

当我访问链接html5Mode(false)@H_404_14@localhost:8000 /#/ – > localhost:8000 /#/ Feed页面不刷新

当html5Mode(true)和我访问@H_404_14@localhost:8000 / – > localhost:8000 / Feed,页面刷新,我收到此错误

Sorry,the page you are looking for could not be found.

我改变了我的route.PHP @H_403_1@Route::get('/',function () { return View::make('index'); }); Route::get('{all}',function () { return View::make('index'); });

添加了一个基数< base href =“/”>到我的index.PHP现在一切正常,页面不刷新.

猜你在找的Angularjs相关文章