Reputation: 3353
Im starting to build a new app with laravel and decided to try out angular.js as well. So I will be using a hybrid approach where the login is made outside angular and then i have a main page where I wanna load the templates using angular.
I got stuck in the loading views part with angular. No errors are shown in the console and the template is not loading as well.
This is my routes.php file:
// Login routes here
...
// Routes protected by auth filter
Route::group(['prefix' => 'admin', 'before' => 'auth'], function(){
Route::get('/', 'AdminPagesController@main'); // Main Page
Route::resource('documents', 'DocumentsController');
});
app/views/admin/layouts/master.blade.php file:
<html ng-app="intern">
<head>
...
</head>
<body>
<div ng-view=""></div>
{{ HTML::script('js/vendor/angular.min.js') }}
{{ HTML::script('js/vendor/angular-route.min.js') }}
{{ HTML::script('js/admin/app.js') }}
{{ HTML::script('js/admin/controllers/documentsController.js') }}
</body>
</html>
public/js/admin/app.js
'use strict';
var intern = angular.module('intern', ['ngRoute'], function($interpolateProvider) {
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
intern.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/admin', {
templateUrl : 'app/views/admin/documents/index.php',
controller : 'documentsController'
});
$routeProvider.otherwise({templateUrl:'app/views/admin/documents/index.php'});
});
public/js/admin/controllers/documentsController.js (which don't have anything much for now)
intern.controller('documentsController', ['$scope', function(scope){
}]);
and finally my template: app/views/admin/documents/index.php
<div>
<h1>index documents</h1>
</div>
what am I doing wrong? If you guys need more information please tell me. Thanks in advance :)
Upvotes: 2
Views: 1272
Reputation: 8524
You have to place your templaes into the public folder since the app-folder is not accessible via request from the browser. Alternatively you can write a route for the templates (which is not recommended in my opinion)
Anyway you should see an error in your network-console (404) cause the template cant be loaded
Upvotes: 1