I have a problem to load some template to "/" index laravel 5 route with angularjs utilizing $stateProvider or $routeProvider or wherever.
The content of index.blade.php is fine, and every time I access directly on web browser the urls to templates everything also is fine.
The problem is load with angularjs. This error present on developer console:
Error: [$compile:tpload] Failed to load template: /templates/site/home (HTTP status: undefined undefined)
So, I customized my laravel routes utilizing {path?} and Route::any().
I utilize templates as prefix but doesn't exists in fact. This is only virtual url to laravel routes to utilize.
This implementation is below:
web.php
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
| Here is where you can register web routes for your application.
| These routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
*/
Route::group(['prefix' => 'panel'], function () {
Route::any('{path?}', function () {
return view('panel/index');
})->where('path', '.+');
});
Route::group(['prefix' => 'templates'], function () {
Route::any('{path?}', function ($name) {
dd($name);
return view($name);
})->where('path', '.+');
});
Route::group(['prefix' => ''], function () {
Route::any('{path?}', function () {
return view('site/index');
})->where('path', '.+');
});
app.js
var panelTplDir = '/templates/panel';
var siteTplDir = '/templates/site';
/***********************************
* Routes of website without panel -
* ---------------------------------
*
* @type
*/
// Routes to out panel.
var siteIndexRoute = {
name: 'index',
url: '/',
templateUrl: siteTplDir + '/home',
controller: 'IndexCtrl as index'
};
var notfoundRoute = {
name: 'notfound',
url: '/not_found',
templateUrl: siteTplDir + '/notfound',
controller: 'SiteCtrl as site',
params: {
route: null,
paramSearch: null
}
};
// Routes of authentication.
var authRoute = {
name: 'login',
url: '/login',
templateUrl: siteTplDir + '/auth/login',
controller: 'AuthController as auth'
};
var registRoute = {
name: 'register',
url: '/register',
templateUrl: siteTplDir + '/auth/register',
controller: 'AuthController as auth'
};
/**********************************
* Routes of administration panel -
* --------------------------------
*
* @type
*/
// Routes of dashboard.
var homeRoute = {
name: 'panelIndex',
url: '/panel/dashboard',
templateUrl: panelTplDir + '/home',
controller: 'DashboardCtrl as home'
};
// Routes of user.
var userMeRoute = {
name: 'me',
url: '/panel/me',
templateUrl: panelTplDir + '/users/user_info',
controller: 'DashboardCtrl as user'
};
var usersRoute = {
name: 'userList',
url: '/panel/users',
templateUrl: panelTplDir + '/users/get_users',
controller: 'DashboardCtrl as user'
};
// Routes of stores.
var storeIndexRoute = {
name: 'storeIndex',
url: '/panel/stores',
templateUrl: panelTplDir + '/stores/index',
controller: 'StoresController as store'
};
And so...
I don't undestand what's happening with templates just out panel route.
.
Here, everything is fine.
.
Here, everything is fine.
.
Here, everything is fine.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire