Я хочу разработать простой интерфейс AngularJS и серверную часть Laravel. Я не знаю, почему мой маршрут AngularJS не связан с маршрутом Laravel. Это постоянно упоминается как GET http://локальный/апи/тодос Внутренняя ошибка сервера.
Привет.php
<html>
<head>
<title>Laravel + Angularjs</title>
<link rel = "stylesheet" type = "text/css" href = "css/bootstrap.min.css">
<script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
</head>
<body ng-App>
<div id = "todos" ng-controller = "Todoctrl">
<h3 class = "page-header">Todos<small ng-if = "remaining()">{{remaining()}} remaining</small>
</h3>
<ul class = "unstyled">
<li ng-repeat = "todo in todos">
<input type = "checkbox" ng-model = "todo.done">
{{todo.text}}
</li>
</ul>
</div>
</script>
<script src = "js/app.js">
</script>
</body>
</html>
Todo.php(модель)
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Todo extends Model
{
protected $guarderd = [];
}
API.php
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::get('/todos',function(Request $request){
return $request->user();
});
app.js
function Todoctrl($scope,$http){
$http.get('api/todos').success(function(todos){
$scope.todos = todos;
});
$scope.remaining = function(){
var count = 0;
angular.forEach($scope.todos,function(todo){
count == todo.done ? 0 : 1;
});
}
}
давайте попробуем добавить middleware('auth:api') к маршруту todo.






Внутренняя ошибка сервера означает, что где-то в ваших журналах содержится полезное сообщение об ошибке. Это может быть в
storage/logs/laravel.log. Найдите ошибку, и она должна быть довольно ясной. Одно замечаю:$guarderd— это опечатка.